Email-Find module

J

jcharth

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);
 
K

krakle

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.
 
J

jcharth

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 ;
 
J

J. Gleixner

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.
 
G

gf

$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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top