Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: My favorite looping mechanism in Perl is:

by Anonymous Monk
on Jun 24, 2012 at 17:02 UTC ( [id://978064]=note: print w/replies, xml ) Need Help??


in reply to Re: RE: My favorite looping mechanism in Perl is:
in thread My favorite looping mechanism in Perl is:

Personally, I find for-as-foreach more useful:

Try make:

for my $i (0 .. $#array) { ... }
efficiently do something like:
for ($i=0; $i < @array; $i += ROWSIZE) { ... }

Replies are listed 'Best First'.
Re^4: My favorite looping mechanism in Perl is:
by jdporter (Paladin) on Jun 25, 2012 at 00:35 UTC

    oh, you mean like

    for my $i ( grep { not $_ % ROWSIZE } 0 .. $#array )

      That would do ROWSIZE mods and ROWSIZE comparisons plus some other junk in place of a single addition.

      -sauoq
      "My two cents aren't worth a dime.";

      Yes. using foreach you have to do something terribly contorted and crazily inefficient. Like that.

      Thank you for so adeptly illustrating my point.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://978064]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found