in reply to Re: grepping for
in thread grepping for
index() is faster when the match occurs at the beginning of the string, but substr() is much better when there is no match at all, which happens quite a lot in this application.
$dir = "/$dir/"; my $strlen = length $dir; while (<LOG>) { my ($url, $code) = (split)[6,8]; if (substr($url, 0, $strlen) eq $dir && $code == $error) { $report{$url}++; } }
|
|---|