foreach($_){
####
my ($num,$date,$time,$fw,$type,$action,$alert,$int,$dir,$proto,$src,$dst,$service,$sport,$len,$rule) = (split /;/,$_);
####
my (undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $dst, $service, undef, undef, undef) = split /;/; # split() works on $_ if only one argument is given.
####
my ($dst, $service) = (split /;/)[11, 12];
####
%hash = (dest => $dst, service => $service);
foreach my $key (keys %hash){
my $val = $hash{$key};
$count{$val}++;
} #close foreach
} #close while
####
$count{$_}++ for $dst, $service;
}
####
foreach my $key1 (keys %count){
print "$key1 appears $count{$key1} times\n";
} #close foreach
####
print map "$_ appears $count{$_} times\n", keys %count;
####
#!/usr/bin/perl -w
use strict;
my $log = './log';
my %count;
open (LOG, $log) or die "Can't open $log: $!";
while (){
my ($dst, $service) = (split /;/)[11, 12];
$count{$_}++ for $dst, $service;
# Now I see it this way, I realise that
# $count{$_}++ for (split /;/)[11, 12];
# would be even better :)
}
print map "$_ appears $count{$_} times\n", keys %count;
####
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$