in reply to Help Matching Sections of a file
to print $line
print $line;
you only want to print it if there was a match before, and if it isn't a #--------------------------------------------:
if ( $line !~ m/^#\-{44}/ ) { undef $match }
# kvale's solution with last
# is probably better because it stops reading lines from the array.
# Use this switch if you are going to print more than one section in the file.
print $line if $match;
You still have to switch on $match = 1 in the code you already have got.
Cheers, Sören
|
|---|