SPUG: Fw: greetings
Russell Miller
duskglow2000 at yahoo.com
Wed Oct 17 20:14:40 CDT 2001
First thing and I screw up. The message is below. Thanks for your help.
----- Original Message -----
From: "Russell Miller" <duskglow2000 at yahoo.com>
To: <spug-list at perl.org>
Sent: Wednesday, October 17, 2001 8:13 PM
Subject: greetings
> Greetings all... just joined the list, because I'm a professional perl
> programmer, and I have a problem I just can't seem to find the answer to,
> and I hope that you can help me out. I'll try to help you guys (gals?)
out
> where I can, too.
>
> ok, we've got a six million line file to read. I had written a program
that
> scaled just fine for smaller files, but it choked on this file, and took
an
> extreme amount of time.
>
> the original code goes like this:
>
> open (FILE, "<$INPUT");
> @array = <FILE>;
> close FILE;
>
> foreach $k (@array) {
> ...
> }
>
> it worked just fine, but very slow and memory intensive for a six million
> line file. So, we changed it to read sequentially:
>
> open (FILE, "<$input");
> foreach $k (<FILE>) {
> ...
> }
>
> which got rid of the memory problem but the speed issue was still there.
So
> I changed the foreach line to:
>
> while ($k = <FILE>) {
>
> and the increase of speed had to be a thousand fold.
>
> What causes that speed impact?
>
> Thanks.
>
> --Russell
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list