Email-Find module

Discussion in 'Perl Misc' started by jcharth@hotmail.com, Jan 23, 2007.

  1. Guest

    Hello Guys I am trying to extract all email from text file using the
    Email-find module and put them in an array
    but i cant seem to figure it out. when i give it a text sample it works
    but it just prints the emails out. How can i put them in an array? or
    just put them in a string variable?
    thanks.

    my $finder = Email::Find->new(sub {
    my($email, $orig_email) = @_;
    print "Found ".$email->format."\n";
    return $orig_email;
    });
    $finder->find(\$text);
     
    , Jan 23, 2007
    #1
    1. Advertising

  2. Guest

    On Jan 23, 2:21 pm, wrote:
    > Hello Guys I am trying to extract all email from text file using the
    > Email-find module and put them in an array
    > but i cant seem to figure it out. when i give it a text sample it works
    > but it just prints the emails out. How can i put them in an array? or
    > just put them in a string variable?
    > thanks.
    >
    > my $finder = Email::Find->new(sub {
    > my($email, $orig_email) = @_;
    > print "Found ".$email->format."\n";
    > return $orig_email;
    > });
    > $finder->find(\$text);


    The emails are printing out because you're printing them out. Hence the
    print statement you are using. If you wish to add them to an array then
    do so.
     
    , Jan 23, 2007
    #2
    1. Advertising

  3. Guest

    thanks for the input, never seen a modules like this one, i put a
    variable inside. not sure, it does not look clean but it works

    my $manyemails1 ="";

    my $finder1 = Email::Find->new(sub {
    my($email1, $orig_email1) = @_;
    my $acutemp1;
    $acutemp1 = $email1->format;
    $manyemails1 = "$manyemails1
    $acutemp1";
    return $orig_email1;
    });
    $finder1->find(\$myfrom);
    $myfrom = $manyemails1 ;

    On Jan 23, 4:16 pm, wrote:
    > On Jan 23, 2:21 pm, wrote:
    >
    > > Hello Guys I am trying to extract all email from text file using the
    > > Email-find module and put them in an array
    > > but i cant seem to figure it out. when i give it a text sample it works
    > > but it just prints the emails out. How can i put them in an array? or
    > > just put them in a string variable?
    > > thanks.

    >
    > > my $finder = Email::Find->new(sub {
    > > my($email, $orig_email) = @_;
    > > print "Found ".$email->format."\n";
    > > return $orig_email;
    > > });
    > > $finder->find(\$text);The emails are printing out because you're printing them out. Hence the

    > print statement you are using. If you wish to add them to an array then
    > do so.
     
    , Jan 24, 2007
    #3
  4. J. Gleixner Guest

    wrote:
    > thanks for the input, never seen a modules like this one, i put a
    > variable inside. not sure, it does not look clean but it works
    >
    > my $manyemails1 ="";
    >
    > my $finder1 = Email::Find->new(sub {
    > my($email1, $orig_email1) = @_;
    > my $acutemp1;
    > $acutemp1 = $email1->format;
    > $manyemails1 = "$manyemails1
    > $acutemp1";
    > return $orig_email1;
    > });
    > $finder1->find(\$myfrom);
    > $myfrom = $manyemails1 ;


    Please, post your reply AFTER, the previous post, instead of before it.

    To make it "look clean", use push.

    perldoc -f push

    e.g.
    my @manyemails1;
    push ( @manyemails1, $email1->format );
    print "@manyemails1\n";

    No need for $acutemp1.
     
    J. Gleixner, Jan 24, 2007
    #4
  5. gf Guest

    wrote:
    > $manyemails1 = "$manyemails1
    > $acutemp1";


    I can't begin to explain how much it hurts to see that.

    For your own future sanity read through the perldata documentation...

    perldoc perldata

    and pay particular attention to the section on arrays and lists. They
    are primary building blocks to storing and accessing data in any
    language, and the basis for hashes in Perl.
     
    gf, Jan 24, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Amadi
    Replies:
    2
    Views:
    404
    chuck amadi
    Jun 6, 2004
  2. Chuck Amadi
    Replies:
    1
    Views:
    311
    fishboy
    Jun 6, 2004
  3. Nico Grubert
    Replies:
    0
    Views:
    882
    Nico Grubert
    Dec 8, 2006
  4. Fredrik Lundh
    Replies:
    0
    Views:
    450
    Fredrik Lundh
    Dec 8, 2006
  5. David Erickson
    Replies:
    6
    Views:
    453
    Dennis Lee Bieber
    Jan 27, 2008
Loading...

Share This Page