in reply to extracting name & email address

Perhaps i could provide something useful, but i don't understand some of your specs: KMail is a KDE email client. Some lines later you talk about Pegasus, a Windows email client. And why do you need to filter out "*.pl" or "*.php" in an mbox folder?

And what does this mean:

"For each file, if the name/email address is not found, add the name/email address to an array"

Anyway, some links:

I guess they might be useful.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: extracting name & email address
by peterr (Scribe) on Feb 23, 2015 at 23:54 UTC
    KMail is a KDE email client. Some lines later you talk about Pegasus, a Windows email client. And why do you need to filter out "*.pl" or "*.php" in an mbox folder?

    I'm using KMail folders/files. Pegasus was an example from years ago. Perl & php files are in the same path. I don't really need to bypass them though, as they won't contain email addresses.

    And what does this mean: "For each file, if the name/email address is not found, add the name/email address to an array"

    Simply to load a unique array , based on name/email address. That isn't important though, as many emails will appear more than once. I can filter out the duplicates later

      The following code works to a point. It is writing name and email address out to a file. The only real problem is the msg "Complex regular subexpression recursion limit (32766) exceeded at /usr/share/perl5/Email/Address.pm line 108."

      #!/usr/bin/env perl # use strict; use warnings; use File::Find; use File::Slurp qw( read_file ); use Email::Address; my $directory = '/home/*****/Mail/.family.directory/Browne, Bill & Ma+ +rtha';'; my $outfile = 'output.txt'; my @found_files; find( sub { push @found_files, $File::Find::name }, $directory ); foreach(@found_files){ my $file = "$_"; if (-f $file) { print $_,"\n"; my $intext = File::Slurp::read_file( $file ); my @emails = Email::Address->parse( $intext ); File::Slurp::write_file( $outfile, {append => 1 }, join("\n", @ema +ils) ); } }

      The file that the warning msg appears has a large attachment. So, somehow need to bypass any attachments in the slurp ?

        Added an attachment 'stripper' module, but now there is no output ..

        #!/usr/bin/env perl # use strict; use warnings; use File::Find; use File::Slurp qw( read_file ); use Email::Address; use Email::MIME::Attachment::Stripper; my $directory = '/home/*****/Mail/.family.directory/Browne, Bill & Mar +tha';';'; my $outfile = 'output.txt'; my @found_files; find( sub { push @found_files, $File::Find::name }, $directory ); foreach(@found_files){ my $file = "$_"; if (-f $file) { print $_,"\n"; my $intext = File::Slurp::read_file( $file ); my $stripper = Email::MIME::Attachment::Stripper->new($intext); my @emails = Email::Address->parse( $stripper ); File::Slurp::write_file( $outfile, {append => 1 }, join("\n", @e +mails) ); } }
        One thing though, it processed all the files very quickly. LOL