<massage> #!/usr/bin/perl -w use strict; my $file = shift; #always! my $start = quotemeta shift; #quote meta chars my $end = quotemeta shift; #quote meta chars my $outfile = "$file.out"; open(IN, "<$file") || die "Can't open $file!\n"; open(OUT, ">$outfile") || die "Can't open $outfile!\n"; my $file_contents = do {local $/; <IN>}; #slurp! while ($file_contents =~ /($start.*?$end)/gs) { print OUT $1, "\n"; } </massage> __infile__ blah blah blah #BG blah blah blah blah blah blah #EN blah blah blah blah #BG blah #EN blah blah blah blah __infile.out__ #BG blah blah blah blah blah blah #EN #BG blah #EN
--
flounder
In reply to Re^2: File Filtering... Help
by flounder99
in thread File Filtering... Help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |