I'm familar with using a hash to parse a file and keep a count of the number of instances something shows up.
while (<INPUTLOG>) {
chop($_);
($timestamp,$sfcat,$sfresult,$username,$clientip,$csuri)=split (/,/,$_);
if ($sfresult eq 1 ){
$count{$sfcat}++;
$count2{$username}++;
$count3{$csuri}++;
}
}
foreach $k (sort {$count{$b} <=> $count{$a}} keys %count) {
print "$k \t$count{$k}\n";
}
I want to parse a file and keep track of multiple things. So instead of just seeing the result: "bsmith 100" I would like to keep track of "bsmith 100".
I've tried $count{$username,$csuri}++ but when it prints out $k I just get a blank.
while (<INPUTLOG>) {
chop($_);
($timestamp,$sfcat,$sfresult,$username,$clientip,$csuri)=split (/,/,$_);
if ($sfresult eq 1 ){
$count{$sfcat}++;
$count2{$username}++;
$count3{$csuri}++;
}
}
foreach $k (sort {$count{$b} <=> $count{$a}} keys %count) {
print "$k \t$count{$k}\n";
}
I want to parse a file and keep track of multiple things. So instead of just seeing the result: "bsmith 100" I would like to keep track of "bsmith 100".
I've tried $count{$username,$csuri}++ but when it prints out $k I just get a blank.