GavilanCode Samples 6a: Logs with hash tables

#!/usr/bin/perl

$file = '../data/small';
open IN, $file;

# read the data file.

while(<IN>){
  $line = $_;
  @a = split(" ", $line);
  if (exists $bypath{$a[6]}) {
    $bypath{$a[6]} += 1;
  } else {
    $bypath{$a[6]} = 1;
  }
}

foreach $p (sort keys %bypath) {
  print "$bypath{$p}\t$p\n";
}