You can still use a lexical but you have to be explicit about what is being matched, also taking care with the difference in precedence of and and &&. With lower precedence and:-
$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<EOD or die $!; Seb Xavier Peter Roland Jim Xerox Paddle Yoyo EOD while ( my $line = <$inFH> ) { print $line if $line =~ m{X} .. $line =~ m{^\s*$} and $line !~ m{^\s*$}; }' Xavier Peter Xerox Paddle $
Higher precedence && requires parentheses:-
$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<EOD or die $!; Seb Xavier Peter Roland Jim Xerox Paddle Yoyo EOD while ( my $line = <$inFH> ) { print $line if ( $line =~ m{X} .. $line =~ m{^\s*$} ) && $line !~ m{^\s*$}; }' Xavier Peter Xerox Paddle $
Cheers,
JohnGG
In reply to Re^4: How to find content between KEYWORD and BLANKLINE then print it
by johngg
in thread How to find content between KEYWORD and BLANKLINE then print it
by ChrisCK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |