Link to home
Start Free TrialLog in
Avatar of QUESTOMNI
QUESTOMNIFlag for United States of America

asked on

Can you write me a script that extracts email addresses from local files.

Hello,
     Can you write me a script that extracts email addresses from local files.

Thanks,
PD GRAVES
Avatar of jmcg
jmcg
Flag of United States of America image

On the face of it, this sounds like an application whose primary use would be harvesting email addresses for spam. Please reassure us as to your intentions.
Avatar of QUESTOMNI

ASKER

No. I have opt-in email I want to process faster so I can make the most efficient use of my time.
I also get emails from those contacting me. Many are businesses.
when can I expect a response? Question:
Can you write me a script that extracts email addresses from local files.

Thanks,
PD GRAVES
Can you write the script so it reads the file from my unix? I can upload the file and the script can read it and extract the email addresses. Is that do-able?
Avatar of turn123
What format is your local file in?
It's windows 98
Can you write the script so it reads the file from my unix? I can upload the file and the script can read it and extract the email addresses. Is that do-able? It is likely easier.
Avatar of kandura
kandura

You could make it as simple as this:

#!/usr/bin/perl

while(<>)
{
      chomp;
      my @emails = /([\w&_-]+(?:\.?[\w&_-]+)*\@[\w_-]+(?:\.?[\w_-]+)*)/g;
      print join($/, @emails), $/ if @emails;
}

#end script

Use it like this:

emailextractor.pl < your_input_file > your_list_of_emailaddresses
I am very much a novice. I looks like the while(<>) is reading each line. Then you chomped the \n. Then you give me a variable set to a valid email address.

After that I'm kind of lost. You seem to be joining the Special variable \n at the end of @emails. Then you put $/ if @emails;
at the end of that. That's where you lose me. Can you tell me what's happening with that?

Can you write it so it only extracts the From: email@address.com
email address one uder the other?

I don't understand the following at all. Please explain:

Use it like this:

emailextractor.pl < your_input_file > your_list_of_emailaddresses

Thanks,
PD GRAVES
ASKER CERTIFIED SOLUTION
Avatar of kandura
kandura

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There can be many characters other than [\w&_-] in email addresses