P0w3rK!d has asked for the wisdom of the Perl Monks concerning the following question:
After finding "[foo]", how do you print out everything
after it until you reach [foo2]? How do you get to the
next element within @lines inside of the foreach? I
only want to read the file 1 time..not n times.
foreach my $line (@lines) { if ($line =~ m/\[foo\]/) { print $line; # I do not want this line # how do I print the next lines in @lines # until I reach [foo2]? # once I get to [foo2] I want to print out # everything there also } }
File:
; ; foo file ; [foo] a=1 b=2 c=3 [foo2] d=4 e=5 f=6
Back to
Seekers of Perl Wisdom