Parsing a file using perl and skipping some lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing a file using perl and skipping some lines
# 1  
Old 12-11-2008
Parsing a file using perl and skipping some lines

Hi,

Consider following file with input:

Code:
`YFLG:NC^Byad_insert constraint {id=600104470} {profile=GENDER == 2} {profile=BEHAVIOR == 17} {profile=SITEATTR_MULT == siteid:211051} {profile=AGE in [30,34]}
yad_insert ad {id=1718286093336959379} {type=R} 
^AYFLG:YOO^Byad_insert constraint {id=600104471} {profile=GENDER == 2} {profile=BEHAVIOR == 17} {profile=SITEATTR_MULT == siteid:211051} {profile=AGE in [30,34]}
yad_insert ad {id=1718286101926893971} {type=R} {secure=1} {AD_LANDING_PAGE=yahoo.com,www.yahoo.com/}

All lines begin with YFLG and end in ^A. I want to skip the lines in between YFLG:NC and the ^A and consume only those lines following YFLG:YOO until the next ^A.

Can someone please tell me how to achieve the same in perl.

Thanks

Last edited by radoulov; 12-12-2008 at 05:15 AM.. Reason: added code tags
# 2  
Old 12-12-2008
Code:
perl -ne'$/=$\="^A";print if /^YFLG:YOO/' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command Line Perl for parsing fasta file

I would like to take a fasta file formated like >0001 agttcgaggtcagaatt >0002 agttcgag >0003 ggtaacctga and use command line perl to move the all sample gt 8 in length to a new file. the result would be >0001 agttcgaggtcagaatt >0003 ggtaacctga cat ${sample}.fasta | perl -lane... (2 Replies)
Discussion started by: jdilts
2 Replies

2. Shell Programming and Scripting

Help in parsing XML output file in perl.

Hi I have an XML output like : <?xml version="1.0" encoding="ISO-8859-1" ?> - <envelope> - <body> - <outputGetUsageSummary> - <usgSumm rerateDone="5"> - <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false"... (7 Replies)
Discussion started by: rkrish
7 Replies

3. UNIX for Dummies Questions & Answers

Appending 2 files skipping the header of the second file

I have 2 files with the same header and need to append them and put the result in a 3rd file the 2 files has the same header and while appending i want to skip the second file header and need the result to be put in a third file Normally, this would work Cat file1 file2 >> file3....But how... (5 Replies)
Discussion started by: saggiboy10
5 Replies

4. Shell Programming and Scripting

Parsing config-file (perl)

Hi, i'm trying to parse a config file that have alot of rows similar to this one: Example value value value What i want to do is to split and save the row above in a hash, like this: Example = value value value Basically i want to split on the first whitespace after the first... (3 Replies)
Discussion started by: mikemikemike
3 Replies

5. Shell Programming and Scripting

Parsing file in perl script

Hi Guys, I have a large text file that is has a bunch of records. Each record starts with a header line that starts with the ">" character. Then there are several lines under that line that contain sequences of letters. For example, a file might look like: >TEXT ID=2L TEXT... (2 Replies)
Discussion started by: maverick.usb
2 Replies

6. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

7. Shell Programming and Scripting

sed delete pattern skipping first n lines of file.

I have files of more than 10K lines that I need to delete lines that contain a pattern, but I want to keep the first few lines intact. Can this be done with sed? (7 Replies)
Discussion started by: tkg
7 Replies

8. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

9. Shell Programming and Scripting

sed skipping the last line in a file

Hello All, I have a file like this: PART A1 PART A2 % PART B1 PART B2 The last line in the file (PART B2) does not end with a new line. i.e <EOF> immediately follows "PART B2". Here is my problem: I want to print everything after '%'. So, I tried: sed '1,/%/ d' . This works... (6 Replies)
Discussion started by: aghoras
6 Replies

10. Shell Programming and Scripting

Parsing Lines from a text file

Hello Guru's I know there are people who live to be able to help people like me. That's why I'm here! I have a text file that has a corresponding address information that I need to be able to get maybe as a Unix Function. The text file contains the following: AIX17_JB_C;... (3 Replies)
Discussion started by: sallender
3 Replies
Login or Register to Ask a Question