On 10/8/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> From: "Chas. Owens" <[EMAIL PROTECTED]>
> > On 10/3/07, Jonathan Lang <[EMAIL PROTECTED]> wrote:
> > snip
> > > Chas shows one possibility.  However, that approach generally involves
> > > slurping the entire file into the perl script, applying the regex to
> > > the whole thing, and then spitting the result out again.  From what I
> > > understand, this generally isn't very good form.
> > snip
> >
> > The reason slurping files is frowned upon is that you do not know how
> > large the file may be.  You may be testing with small files, but
> > production may be using multi-gig files.  Source files are almost
> > always less than a few megabytes (and if they aren't you have a bigger
> > problem than a slurp).
>
> If I found a source file that would be even just one megabyte, I'd
> first make sure it's really a source file and not a generated
> intermediate file and if it's not I'd go and start shouting at the
> person that created the file. (Yes, I do have a "source" file that's
> 1.08MB. It's generated.) In this case I'd check that the size is
> reasonable and slurp. It'll make the code much simpler.
snip

Yeah, most source code files are smaller than 250k, but one to two
megs covers the outliers.  The point is that slurping is only bad if
you don't know how big the files are going to be.  If source code
grows large enough to matter then you have more serious problems than
a Perl script eating a lot of memory (also, if Perl can't slurp it,
how do you edit it? with ed/edlin?).

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to