SPUG: multiline matching question

Richard Wood wildwood_players at yahoo.com
Thu Sep 8 15:23:07 PDT 2005


I am trying to efficiently grab sets of data from
multiple lines of a file and print the collected data
out on one line per set.  I've never tried multi line
matching before ( I usually just write a program that
tests which kind of line I am processing).  But I
believe that this can be done in one match statement. 
So I would like some help.  Currently, in the test
file that I am including, I am getting the data from
the second set of lines which seems pretty unusual to
me.  I'm looking forward to understanding what I am
doing wrong.

The file consists of 150 character records.  Every
third record starts a new set of data.  I need bits
and pieces from records 1 & 2 of each set.  

here is the command line that I am using:

$ perl -wne 'undef
and print "$1 $2 $3 $4 $5 $6\n";' sample.txt   

based on this sort of working, I also tried this:

$ perl -wne 'undef
and print "$1 $2 $3 $4 $5 $6\n";' sample.txt   

but it didn't work any better/worse.

I am attaching the sample.txt file, which has 4 sets
of records.  When I run the command, as I say, I get
the second of the 4 sets of data:

AP01 AZ 468 71-70-0      0000    100  ENGINE DRAINS   

Thanks in advance for your thoughts, 

Rich Wood

Richard O. Wood
Wildwood IT Consultants, Inc.
wildwood_players at yahoo.com
425.281.1914 mobile
206.544.9885 desk

Click here to donate to the Hurricane Katrina relief effort.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sample.txt
Url: http://mail.pm.org/pipermail/spug-list/attachments/20050908/7738f32b/sample.txt

More information about the spug-list mailing list