#perl - Fri 9 Mar 2007 between 09:36 and 09:53

NY Lost Funds



spyroboywait, got an idea.
Uh yeah..
blue_skyI have a file with 1.2 million lines over which I have to iterate. Which is faster, while or foreach?
maukewhile
Ani-_Depends on how you use it.
Botjeif you have to ask, you're probably not fit to be handling 1.2M line files ;)
CaT[tm]ooooooo
Botjehello for qw(mauke Ani-_ f00li5h CaT[tm])
Ani-_You should read the file line by line using while. You should not read the entire file in an array and then use a while to loop over it.
fbredor maybe 1000 lines a time?
Ani-_line per line.
Let Perl handle the buffering
actionCPAN upload: Mediawiki-POD-0.03 by TELS
CPANupload: Mediawiki-POD-0.03 by TELS
Teratogendoesn't thee operating system handle file buffering?
matteocpan> i /Video::Info/
Module Video::Info (N/A)
Teratogendemand paging
matteoi guess it is unavailable
Khisanthyour metadata file is wrong
blue_skymauke, thanks... hey, and Botje, I may not have the experience, but some bugger's gotta do this :)
Botjeagreed :p
blue_skyAni-_, I shall not, as you suggest, read it into an array first! (I'm *not* that dumb... contrary to popular belief)
Khisanththen why did you ask about foreach? ;)
Ani-_(blue_sky: what Khisanth asked)
I was typing the same thing...
foreach (<FH>) { } will first read the entire FH
into memory
f00li5htrusty old list context
blue_skyjust in case I was missing something, 1.2 mil. lines is more than I've handled before and I dont' want to cripple the system while its doing this
spyroboylol
blue_sky, add a fractional script pause at the end of every line.
don't ask me how, should be something like sleep(.025);
Ani-_eval: sub s1 { print ((wantarray ? "" : "no ") . "wantarray"; 0 } for (; s1 ; ) { }
buubotAni-_: Error: syntax error at eval line 1, at EOF
Ani-_eval: sub s1 { print ((wantarray ? "" : "no ") . "wantarray"; 0; } for (; s1 ; ) { print "a" }
blue_skythanks for the suggestions all,.... spyroboy I'll think about it, thanks.
buubotAni-_: Error: syntax error at eval line 1, at EOF
maukeeval: sub s1 { print ((wantarray() ? "" : "no ") . "wantarray"; 0 } for (; s1 ; ) { }
KhisanthAni-_: missing )
buubotmauke: Error: syntax error at eval line 1, at EOF

Page: 2 9 16 23 30 37 44 51 58 65 72 79 

IrcArchive

NY Lost Funds