Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: RE: My favorite looping mechanism in Perl is:

by BrentDax (Hermit)
on Jul 06, 2001 at 10:20 UTC ( #94391=note: print w/ replies, xml ) Need Help??


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

Uh...why?

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

for my $i(0..$#array) { #same thing as your C-like for stuff; }

=cut
--Brent Dax

@HPAJ=split("", "rekcaH lreP rentonA tsuJ"); print reverse @HPAJ; #sucky but who cares?


Comment on Re: RE: My favorite looping mechanism in Perl is:
Select or Download Code
Replies are listed 'Best First'.
Re^3: My favorite looping mechanism in Perl is:
by Anonymous Monk on Jun 24, 2012 at 17:02 UTC
    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) { ... }

      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
Node Status?
node history
Node Type: note [id://94391]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-08-28 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (334 votes), past polls