ChrisCK has asked for the wisdom of the Perl Monks concerning the following question:
If Line contains X
Print that line and all next lines until a blank line appears
Can someone give me a good starting point for this?
I'm able to print the line that I have found X on but can't seem to get all the next lines included.
This is what I've started with-
Thanks for any help!use strict; use warnings; my $file = $ARGV[0]; open( my $fh, '<', $file ) or die "Can't open $file: $!"; while ( my $line = <$fh> ) { if ( $line =~ /X /i ) { print $line; } } close $fh;
|
|---|