Steve Grazzini wrote: > > On Thu, Nov 13, 2003 at 12:09:24PM -0800, John W. Krahn wrote: > > Rob Dixon wrote: > > > For the subscribers who don't already know, > > > what are the differences between my > > > > > > print for 1..5 > > > > for iterates over the list 1..5 and sets $_ with each value and then > > print is called for each item and print out the value in $_. > > Not exactly -- it iterates over the *range*, and the range operator > doesn't need to generate a temporary list here. > > print 1 .. $BIGNUM; # creates list of $BIGNUM scalars > print for 1 .. $BIGNUM; # creates/discards one scalar at a time > > This is a documented optimization w/r/t foreach() loops, but the same > thing applies to the foreach() modifier.
It depends on which version of Perl you are using. :-) Older Perls would generate the list first and then iterate over it so that using a C style for loop would be more efficient. When I used the phrase "iterates over the list" I was refering to the concept, not the actual implementation. :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]