in reply to Matching string, then getting next line
Hi minixman
It would be worth trying a slightly different approach to the problem. You have mentioned that your content is coming from a file, it would be easier to work with the file itself line by line, look for the match and then do something with the next line. e.g.
while (<MYFILE>){ chomp; #remove line feed if (/do the match here/) { my $nextLine = <MYFILE>; # do stuff with the next line here. } }
This reads the content of the file handle, line by line placing each line into the default $_ variable. You can test to see if you have a match and then take another line from the file.
If you have all of your content in a list then you can substitute the reading of a line from the file with a shift of a line form the list.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Matching string, then getting next line
by minixman (Beadle) on Mar 08, 2006 at 11:09 UTC | |
by inman (Curate) on Mar 08, 2006 at 11:35 UTC | |
by minixman (Beadle) on Mar 08, 2006 at 11:53 UTC | |
by wazoox (Prior) on Mar 08, 2006 at 13:05 UTC | |
by minixman (Beadle) on Mar 08, 2006 at 14:03 UTC | |
| |
by cas2006 (Novice) on Mar 08, 2006 at 23:47 UTC |
In Section
Seekers of Perl Wisdom