[ back to toc ]

Read File - get email addresses

Date: 2002/01/31 10:21

Q:
Hello Peter!

Im just a beginner/medium perl coder learning it by myself till now.. Its
just mostly easy, perl really rules hehe :)

Currently im programming some stuff for my homepage, but i got one
special part i cant solve, maybe you can help me!

I just want to open diffrent files scan each line for email addresses, if
found get email -> insert into new file members.txt for example.

i think you can get the email out of a line by scanning for the '@' then
get content before and after a space , ie. ' bla@test.com ' , but youre
the expert :-)

it should look a little like following..

$file = 'members';

open(INF,$file);
@ary = <INF>;
close(INF);

open(INF,">$file");

foreach $details (@ary)
{

?? ($email)=split( ????? ,$details); <- HELP :)

print "$email\n\n";

}

close(INF);

Would be cool if you could answer me cause today is programming day and
tommorow i have to work again ahhh :-) ...

Many thanks,

Greetings from Germany
*NAME-DELETED* *NAME-DELETED*
A:
open(F,"test.txt");
@ary = <F>;
close(F);

foreach $details (@ary)
{

while( $details =~ /([\w\.\-]+\@[\w\.\-]+\.[\w\.\-]+)/g ){
print "$1\n";
}

}

[ back to toc ]