Re: Nested loop On 4/20/07, yitzle  wrote: > There's been mentions of efficiency. > I'm under the impression that for the uses Perl is put to, the > efficiency of a loop is sorta irrelevent. If you are doing > harddrive/network access, the performance gain of one loop over the > other is more of less invisible. > Come to think of it, the time for interpretting got to overshadow the > performance gain... I was trying to address all arguments for the use of C-style for.  In general, though, premature optimization is a waste of time.  You should be aware of the general cost of the constructs you use (that is why I occasionally post benchmarks for alternate algorithms), but you should be more concerned with making what you write clearly express your intent.  This is why I prefer my @a = (0 .. 10); my $i = 0; for my $elem (grep {not $i++ % 3} @a) {        func($elem); } to for (my $i = 0; $i < @a; $i += 3) {     func($a[$i] } The grep clearly states that I am looking for something and its block tells me what the criteria are. > For running mathematical stuff, wouldn't you use C? Nah, Fortran. --  To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org http://learn.perl.org/