#!/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"; }
You just needed to read the mailbox file so you could pass it to the find() method.
You should also become familiar with the Mail::Address module, since that's what is passed to your callback routine.
You didn't indicate what you actually wanted to do with the addresses, so in this example I'm just storing them in a hash.
In reply to Re: Email::Find question
by mla
in thread Email::Find question
by cajun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |