Click here to get back home

extract all hotmail email addresses in a file and store in separate file

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
extract all hotmail email addresses in a file and store in separate file Dennis 06-18-2008
Posted by pete on June 19, 2008, 8:25 am
Please log in for more thread options
Bartc wrote:
>>
>>> Dennis wrote:
>>>> Hi, I have a text file that contents a list of email addresses like
>>>> this:
>
>>> /* BEGIN new.c output */
>
>>> <snip 250+ lines of C >
>
>> Wow - All that just to separate @hotmail.com from anything else ? I'm
>> glad I stuck with perl :)
>
> I think pete just enjoys writing huge amounts of C code. Or showing off..

I can see why you might think that.

> I thought my 50-line answer (posted to comp.lang.c only) might have been a
> bit long because it didn't make clever use of scanf(), but at least it could
> deal with /any number/ of email addresses from a file.
>
> This code I /think/ only deals with the 4 email addresses in the OP's
> example..

It deals with how many and whichever string literals
are placed into this macro:

#define STRINGS \
{ "\"foo@yahoo.com\"", "\"tom@hotmail.com\"", \
"\"jerry@gmail.com\"", "\"tommy@apple.com\""}

The program uses the STRINGS macro to initialize the input file.

--
pete

Posted by Martijn Lievaart on June 19, 2008, 2:38 am
Please log in for more thread options
On Wed, 18 Jun 2008 12:33:45 -0700, Dennis wrote:

> Hi, I have a text file that contents a list of email addresses like
> this:
>
> "foo@yahoo.com"
> "tom@hotmail.com"
> "jerry@gmail.com"
> "tommy@apple.com"
>
> I like to
>
> 1. Strip out the " characters and just leave the email addresses on each
> line.
> 2. extract out the hotmail addresses and store it into another file. The
> hotmail addresses in the original file would be deleted.

perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file

HTH,
M4

Posted by Martijn Lievaart on June 19, 2008, 1:55 pm
Please log in for more thread options
On Thu, 19 Jun 2008 08:38:40 +0200, Martijn Lievaart wrote:

> perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file

Or even:

perl -nie 's/"//g; print if /\@hotmail.com@$/' text_file

M4

Posted by Dr.Ruud on June 20, 2008, 5:32 am
Please log in for more thread options
Martijn Lievaart schreef:
> On Thu, 19 Jun 2008 08:38:40 +0200, Martijn Lievaart wrote:

>> perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file
>
> Or even:
>
> perl -nie 's/"//g; print if /\@hotmail.com@$/' text_file

Don't you mean this?

perl -ne 's/"//g; print if /\@hotmail\./' text_file

--
Affijn, Ruud

"Gewoon is een tijger."

Posted by Martijn Lievaart on June 20, 2008, 4:27 pm
Please log in for more thread options
On Fri, 20 Jun 2008 11:32:27 +0200, Dr.Ruud wrote:

> Martijn Lievaart schreef:
>> On Thu, 19 Jun 2008 08:38:40 +0200, Martijn Lievaart wrote:
>
>>> perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file
>>
>> Or even:
>>
>> perl -nie 's/"//g; print if /\@hotmail.com@$/' text_file
>
> Don't you mean this?
>
> perl -ne 's/"//g; print if /\@hotmail\./' text_file

I think I ment this:

perl -ni -e 's/"//g; print if /\@hotmail.com@$/' text_file

(-i makes a backup, -ie probably takes the 'e' as the backup suffix.)

M4

Similar ThreadsPosted
Regex for finding email addresses inside text file January 27, 2005, 1:44 am
how to separate all but www addresses? September 26, 2004, 1:41 pm
Validating email addresses August 10, 2004, 9:26 pm
parsing email addresses July 18, 2005, 10:32 pm
Regexp for email addresses. February 14, 2007, 4:55 pm
FAQ 4.65 How can I store a multidimensional array in a DBM file? May 12, 2005, 11:03 am
FAQ: How can I store a multidimensional array in a DBM file? October 10, 2004, 5:10 pm
FAQ 4.65 How can I store a multidimensional array in a DBM file? February 13, 2005, 12:03 am
FAQ 4.65 How can I store a multidimensional array in a DBM file? July 28, 2005, 10:03 am
FAQ 4.65 How can I store a multidimensional array in a DBM file? September 17, 2005, 10:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap