in reply to Re^2: Lost in Perl - text file searching and printing
in thread Lost in Perl - text file searching and printing
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { if ( $_ =~ m/([?.,]$)/){ # print " matching first criteria $_"; #now check for 'it', using capture parenthesis #for the text before and after 'it' if ( $_ =~ m/(.*)it(.*)/ ){ print "$2\n"; # the second capture parenthesis } }; } __DATA__ 4 score, and 7 years ago? our ? forefathers came, upon it -- a continent. it was it was it ? foo? .bar bazz __END__
|
|---|