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 vippstar on June 19, 2008, 6:55 am
Please log in for more thread options
>
>
>
>
>
>
>
> >> >> 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..
> > Or using concrete functions he has written in the past to write
> > concrete programs.
>
> I thought it was some sort of unwritten rule here that when posting code
> solutions you tend not to import large elements of your own library.
> Otherwise everyone would post their own different version of getline() and
> so on.
There's no such rule
> And also there's the possibility, as seems to have happened here, of using
> something inappropriate just because it's there. There's no reason at all to
> use a linked list to read all the input into memory (and risking
> out-of-memory or thrashing for large input).
What do you mean thrasing? The code risks nothing as all the calls to
malloc, etc are checked.
> (Although I suspect pete may have created this over-the-top solution on
> purpose..)
Yes, presumably the purpose was to provide the newbie with a concrete
example
> > concrete programs.
>
> Which is more concrete, this code which has a memory requirement of N or
> code using fixed memory?
It doesn't matter as long as error checking is there.

Posted by Bartc on June 19, 2008, 7:29 am
Please log in for more thread options
vippstar@gmail.com wrote:

>>...There's no
>> reason at all to use a linked list to read all the input into memory
>> (and risking out-of-memory or thrashing for large input).

> What do you mean thrasing? The code risks nothing as all the calls to
> malloc, etc are checked.

I mean the slow-down that occurs when memory gets nearly full.

>> Which is more concrete, this code which has a memory requirement of
>> N or code using fixed memory?
> It doesn't matter as long as error checking is there.

No, "Sorry out of memory" is just as acceptable as "Task completed"!

--
bartc



Posted by vippstar on June 19, 2008, 7:39 am
Please log in for more thread options
> vipps...@gmail.com wrote:
> >>...There's no
> >> reason at all to use a linked list to read all the input into memory
> >> (and risking out-of-memory or thrashing for large input).
> > What do you mean thrasing? The code risks nothing as all the calls to
> > malloc, etc are checked.
>
> I mean the slow-down that occurs when memory gets nearly full.
While true this has nothing to do with C.

> >> Which is more concrete, this code which has a memory requirement of
> >> N or code using fixed memory?
> > It doesn't matter as long as error checking is there.
>
> No, "Sorry out of memory" is just as acceptable as "Task completed"!
A concrete example of code is one that cannot "break", ie behave
unexpectedly.

Posted by santosh on June 19, 2008, 9:04 am
Please log in for more thread options
Bartc wrote:

>
>
>>>
>>>
>>> > This was the
>>>
>>> >> 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..
>
>> Or using concrete functions he has written in the past to write
>> concrete programs.
>
> I thought it was some sort of unwritten rule here that when posting
> code solutions you tend not to import large elements of your own
> library. Otherwise everyone would post their own different version of
> getline() and so on.

As it is, everyone does post different versions of code for the same
task (as this thread itself has brilliantly illustrated), so as long as
the post contains all the code to compile into a working program in a
self-sufficient manner, I don't see any harm in including something
from a personal library.

And pete has pre-written functions to read files into linked-lists. He
often posts a link to his website containing this and other C code
occasionally here in clc.

> And also there's the possibility, as seems to have happened here, of
> using something inappropriate just because it's there. There's no
> reason at all to use a linked list to read all the input into memory
> (and risking out-of-memory or thrashing for large input).

Well reading a file into a linked-list isn't exactly inappropriate, but
it may be overkill for the small fragment that the OP posted. But it
could be that the OP's actual file contains hundreds or thousands of
email addresses. Constructing a linked-list will obviously take more
storage than a plain linear array, but it makes some tasks like sorting
lines, inserting lines, deleting lines, etc., much more easier. I
suspect that this is the reason why pete uses them.

> (Although I suspect pete may have created this over-the-top solution
> on purpose..)

Hmm.

>> concrete programs.
>
> Which is more concrete, this code which has a memory requirement of N
> or code using fixed memory?

Either code could run out memory on a sufficiently memory starved
system. Besides the linked-list approach has other advantages (which
may not be very pertinent to the particular task the OP wanted) which
must be considered in a fair comparison.


Posted by pete on June 19, 2008, 6:11 pm
Please log in for more thread options
santosh wrote:

> Well reading a file into a linked-list isn't exactly inappropriate, but
> it may be overkill for the small fragment that the OP posted. But it
> could be that the OP's actual file contains hundreds or thousands of
> email addresses. Constructing a linked-list will obviously take more
> storage than a plain linear array, but it makes some tasks like sorting
> lines, inserting lines, deleting lines, etc., much more easier. I
> suspect that this is the reason why pete uses them.

I like to convert lines to strings: the opposite of what puts does;
because strings are easy to work on in memory,
and strings are easy to write as lines to files, like puts does.

Linked lists are good to store pointers to strings.

--
pete

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