use strict; # Declare vars my @columns = (); my %hash = (); my $key = ""; # Open data file open INFILE, "data.tmp"; # Process file line by line while () { # Split on comma delimiters @columns = split(/,/, $_); # Store a number in a hash $key = $columns[3] . "," . $columns[4]; if (defined($hash{$key})) { $hash{$key} = $hash{$key} + 1; } else { $hash{$key} = 1; } } # Output the hash foreach $key (keys %hash) { @columns = split(/,/, $key); print "$columns[0] has accessed $columns[1] $hash{$key} time(s).\n"; }