Look at the precedence of operators, =~ is of higher precedence than ... So $record=~ /^start\b$/ .. /^end\b$/ is interpreted as (scalar $record =~ /^start\b$/) .. (scalar /^end\b$/) (in this case the scalar keyword doesn't change the result, so you can pretend they are not there to make it clearer). So you actually have: (scalar $record =~ /^start\b$/) .. (scalar $_ =~ /^end\b$/) because match operations work on $_ by default.
should work better. Or $record =~ /^start\b$/ .. $record =~ /^end\b$/ if you want to use $record, but that looks more noisy.while (<CHECKBOOK>) { if (/^start\b$/ .. /^end\b$/) { print MYOUTFILE "$file;$_\n"; } }
In reply to Re: how to extract text between 2 strings on separate lines
by Eily
in thread how to extract text between 2 strings on separate lines
by ozosan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |