in reply to extracting name & email address

Is there a question?

Perl is the programming world's equivalent of English

Replies are listed 'Best First'.
Re^2: extracting name & email address
by peterr (Scribe) on Feb 23, 2015 at 08:12 UTC
    The code below has a few errors. All I want to be able to do at first, is to load an array with all the filenames after a recursive path search.
    use strict; use IO::File; my $directory = '/home/******/Mail/.family.directory/Browne, Bill & Ma +rtha'; opendir(DIR,$directory); my @files = readdir(DIR); closedir(DIR); foreach(@files){ $f = new IO::File::open; while (<$f>) { //.. something here... } print $_,"\n"; }
    Is this how to approach this ?

      For finding all files recursively, just use File::Find.

      use File::Find; my @found_files; find( sub { push @found_files, $File::Find::name }, $directory );
        Thanks, the following lists only files, so that's a good start.
        use strict; use File::Find; my $directory = '/home/******/Mail/.family.directory/Browne, Bill & Ma +rtha'; my @found_files; find( sub { push @found_files, $File::Find::name }, $directory ); foreach(@found_files){ my $file = "$_"; if (-f $file) { print $_,"\n"; } }
        I will have to have a read up on arrays, and see how to delete certain entries from @found_files.I see that grep can be used. Possibly best to load another array with the (unwanted) filenames.

      Is this how to approach this ?

      Maybe

      Consider

      Main( @ARGV ); exit( 0 ); sub Main { my @files = RecursivePathSearch( $path ); for my $file ( @files ){ SomethingHere( $file ); } } sub RecursivePathSearch { my( $path ) = @_; use File::Find::Rule qw/ find rule/ return rule( file => not_name => [ '*.pl', ], )->in( $path ); } sub SomethingHere { my( $file ) = @_; use Path::Tiny qw/ path /; use Email::Address; my $stuff = path( $file )->slurp_raw; return Email::Address->parse( $stuff ); }
        Thanks, just had to place a ";" on the 'find rule/' line. Then ran it and a msg appeared "Complex regular subexpression recursion limit (32766) exceeded at /usr/share/perl5/Email/Address.pm line 108."

        There are only 3 sub folders though in that path.

Re^2: extracting name & email address
by peterr (Scribe) on Feb 23, 2015 at 05:22 UTC
    Yes, my question would be - "How do I do the other 3 steps please" ?

      Yes, my question would be - "How do I do the other 3 steps please" ?

      Hmm :) 1) write some code or 2) hire a programmer

      Which would you like to try?