On Thu, Oct 02, 2003 at 05:17:34PM +0200, Thomas B?tzler wrote:
> Todd Wade <[EMAIL PROTECTED]> wrote:
> > "Gary Stainburn" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > print while(<FH>);
> 
> This is bad because it first pulls in the file to
> build the list.

It doesn't.  The "while" modifier is a looping construct.
Except for the lack of a block, these are exactly the same.

  print while <FH>;

  while (<FH>) { print }

They both read and print one-line-at-a-time.

> > print <FH>;
> > 
> > print takes a list of arguments:
> 
> Just to be nit-picking (and to repeat what I learned
> from a M.J. Dominus talk at YAPC::EU this year ;-))
> 
> "print'ing a list is slower than printing a single
> (large) scalar."
> 
> In this particular case it might be worthwhile to
> use "slurping":

But this does load the whole file in memory, and that really
is sloppy.  Sometimes you know the file is going to be small,
and so the sloppiness is acceptable, but the general rule is:
don't slurp files unless you have to.  It doesn't scale.

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to