foreach (@count) {
if ($_->[0] eq $bn) {
$_->[1]++;
$found = 1;
last;
}
}
if ($found == 0) {
push @count, [ $bn, 1 ];
}
####
++$count{$bn};
##
##
my $regex = join '|', @mask;
# Now you have a list of alternatives
$regex = qr;
# now the regex is precompiled
##
##
if (/$regex/) {
s/.*GET //;
s/ HTTP.*//;
:
:
##
##
if (s/$regex/$1/) {
:
:
##
##
use strict;
use File::Basename;
my %count;
my @mask = (
'/some/path/',
'some/other/path',
'another/path',
);
my $regex = join '|', @mask;
# Now you have a list of alternatives $regex = qr
# now the regex is precompiled
# N.B. I added \b to make the filename only match on word boundaries.
# So some/path won't match anothersome/path
# but it will match another/some/path
open F, "access.log";
while () {
if (/$regex/) {
++$count{basename($1)};
}
}
foreach (sort keys %count) {
print $_," = ",$count{$_},"\n";
}