#!/usr/bin/perl -w our $MAILBOX = './mail/addresses'; use strict; use Email::Find; use IO::File; # Read the mailbox my $fh = IO::File->new($MAILBOX) or die "unable to read mailbox '$MAILBOX': $!"; my $mail; { local $/; $mail = <$fh>; } # Find addresses my %addy; my $finder = Email::Find->new( sub { my($email, $orig_email) = @_; $addy{ $email->address }++; return $orig_email; } ); $finder->find(\$mail); foreach my $address (keys %addy) { print "$address $addy{ $address }\n"; }