#!/usr/bin/perl -w # a quick and dirty way to pull e-mail addresses out of a mail file # not overly pretty and there's probably a better way to do it, but... # written by J K Hoffman on 1-7-07 our $MAILBOX = $ARGV[0]; use strict; use Email::Find; use IO::File; # What time are we going to start this mess? my $st = localtime; print "Process started at $st\n"; # 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"; } # What time did it end? my $et = localtime; print "Process ended at $et\n";