i don't know if this helps but you could play around with regex and do some thing like this :
it does exactly this:use strict; print"Please type the term you're looking for\n"; chomp (my $cho = <STDIN>); open (FILE, "<", $ARGV[0]) || die "$!"; $/ ="(.*)\n(.*)\n(.*)"; while (<FILE>){ m/(.*)\n(.*)\n(.*)/gi; next if (!m/(.*)\n$cho\n(.*)/ ); print "$1\n$cho\n$2"; } $/ = "\n";
there are many ways to do it ! but it depends if this is what you actually need. here i've just changed the recognition pattern (input record separator) from \n (which is standard) to stuff\nyour_stuff\nstuff and then evaluate the middle pattern to your pattern. read more about $/ here.fff aaa aaa bbb => bbb ccc ccc ddd
In reply to Re: Extracting Lines of a text file
by baxy77bax
in thread Extracting Lines of a text file
by fatfinger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |