> On Jan 22, 2004, at 12:18 PM, Dan Muey wrote: > > > There are always comments like "you can slurp the file as > long as it's > > not too big" or "becareful not to slurp a really big file > or you'll be > > in trouble". > > > > So what I'd like to survey is what would be what the safest > max size > > of a file that one should ever slurp and why? > > (IE if you have 128 MB of RAM and try to slurp a 768MB > file that'd > > cause issues) > > (IE if the max file size on your system is 2GB you may > have isseus > > slurping a 4 GB file.)
I also found this article form the author of File::Slurp ,Uri Guttman http://www.perl.com/pub/a/2003/11/21/slurp.html Very informative indeed. > > This question is pretty hardware dependent. On my Dual G5 2 > Ghz with 2 MMMMM Dual G5, ohhohohho I just got a 17" G4 PowerBook which lets me develop Perl stuff wherever I go and run it in apache right then and there. > GB RAM, I don't have to worry too much about what I slurp. > That won't > be the case for a lot of machines though. I can even imagine > situations where it wouldn't be wise to slurp big files, even if the > machine could handle it. > > If I had to come up with a solid "guideline" to tell people, it would > probably be don't worry too much about slurping a file that's > a fourth > of your RAM or less. I must stress that is a "guideline" > though, not a > safe rule. > > Generally, my decision process goes like this. > > Do I only need one line at a time? If yes, don't slurp. > > Could I read a "group of lines" at a time? (Generally with something > like "paragraph mode".) If yes, go that way. > > Is what I'm doing a lot easier if I slurp the file? If no, DON'T DO > IT! There's no point. > > If yes, I finally examine if there is a good reason I shouldn't slurp > the file? (Execution hardware not up to it. Multiple copies of the > process will be run in parallel. Whatever.) > > By this point, if I haven't talked myself out of it, I slurp the file. > > How much you know can be a big factor too. If you're going > to run the > script on your machine, once every night as a cron job or as > a one shot > data munge, you know a lot and should feel pretty safe. If you're > going to upload the script to the CPAN and encourage people to run it > everywhere all the time, even on their toaster, try to keep the > memory/processor footprint as reasonable as possible, which may rule > out slurping. > > I think the important thing to stress is that it's a choice. > It often > makes things easier, so don't be ashamed to make that choice, when it > does and won't hurt anything. However, be aware that it > COULD be a bad > choice. Think it through. > Good info James. Thanks > James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>