Here's a program I use to count messages in my mailfile:

  #!/usr/bin/perl -w

  while (<>) {
    if (($who) = /^From\s+\S+\s+\S+\s+(\S+\s+\S+)/) {
      @r = reverse split ' ', $who;
      $r[0] = sprintf("%02d", $r[0]);
      $count{"@r"}++;
    }
  }

  foreach (sort keys %count) {
    printf("%s: %3d\n", $_, $count{$_});
  }

Here's the corresponding perl6 program:

  #!/usr/bin/perl -w

  while (<$ARGS>) {
    if (($who) = /^From\s+\S+\s+\S+\s+(\S+\s+\S+)/) {
      @r = reverse split ' ', $who;
      @r[0] = sprintf("%02d", @r[0]);
      %count{"@r"}++;
    }
  }

  foreach (sort %count) {
    printf("%s: %3d\n", $_, %count{$_});
  }

Notice the variable changes: %count{...} because I'm talking about the
hash %count.  @r[0] because I'm talking about the array @r.  

Nat

Reply via email to