use strict; # Always use IO::File; # I like to localize filehandles. sub CountPatternInFile { local $/; my ( $filename, $pattern, $stop_pattern ) = @_; my $fh = IO::File->new( $filename ) or die $!; $_ = <$fh>; close $fh or warn $!; ($_) = split /$stop_pattern/; return s/($pattern)/$1/g; }
In reply to RE: RE: Counting occurances of a pattern in a file
by Adam
in thread Counting occurances of a pattern in a file
by MadraghRua
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |