[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] A major screw-up: infinite loop



On Mon, Jul 31, 2000 at 12:02:16PM -0400, Bernie Cosell wrote:
> On 31 Jul 2000, at 11:21, Kingpin wrote:
> 
> > Does the "bug" go away if you use the PROPER elegant
> > 
> > for my $i (1..$upper)
> > 
> > instead of that HORRID old C-syntax for-loop?
> 
> Elegance is in the eye of the beholder, I guess, but does anyone know any 
> benchmarks/rulesofthumb for the relative efficiencies of the two?  I'd 
> think that the increment/test version would be faster than the build-a-
> huge-list version, at least if you had a lot of values to iterate over.


for my $i ($tiny .. $huge) { } doesn't build a large list. It's optimized.

$ time perl -wle 'for ("aaaaaaa" .. "zzzzzzz") {exit if /d/}'
real    0m0.030s
user    0m0.010s
sys     0m0.000s
$


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe