Date: 14 Sep 2001 21:50:05 GMT From: damian@qimr.edu.au (Damian James) Subject: Re: Perl (slurping) is TOO much fun Message-Id: Tad McClellan chose Fri, 14 Sep 2001 15:18:03 GMT to say this: >Damian James wrote: >>... >>So it depends on how mauch RAM you have, and and how big the file is. > >And how many copies of this perl process might be running at the same time. >And how often the program will be run. Indeed, I had meant to allude to this in some way or other. >And perhaps how much swap space you have. Hopefully one would move to a line-by-line approach before that became an issue. >My default approach is to do it line-by-line. As is mine, even in many cases where slurping is easier. I guess I'm not being very consistent there :-). I complain about the ridiculous RAM requirements of a lot of today's software often enough, c'est la vie. >>... >>whenever you are sure the file won't become too big (for values of 'too >>big' that are appropriate to your system, taking into account the overheads >>of the OS, Perl and how many users there will be at any one time). > >And for appropriate values of the "sure" in "whenever you are sure". Indeed - ones that include due regard to the future use of the system in question. >>Remember that these days RAM is cheap and you need a lot of data to use it >>up. And reading from RAM is much faster than reading from disk. > >I don't usually slurp to get "faster". I slurp to get "easier to write" >or "easier to maintain" though (labor is my default "thing to optimize"). Likewise, and this was really an afterthought -- people seem to be attracted to micro-optimisations like that. [aside: Oh Lord, let me optimise better for labour -- spent two hours yesterday tracking an extremely subtle bug that turned out to be caused by bad laziness, reusing a subsystem for an other-than-planned purpose without generalising it sufficently]. I guess I hadn't meant to sound so strident in advocating slurping, I had meant to point out that one doesn't need to avoid it for the sake of avoiding it. That would be merely an aesthetic practice. Of course robust programming that takes into account a wide variety of scenarios will attempt to use as little RAM as possible. Cheers, Damian -- @:=grep!(m!$/|#!..$|),split//,;@;=0..$#:;while($:=@;){$;=rand $:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,, $,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__ Just another Perl Hacker, ### rev 3.3 -- stupidectomy performed :-)