Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: looping over multidimensional arrays

by haukex (Archbishop)
on Sep 23, 2018 at 08:02 UTC ( [id://1222880]=note: print w/replies, xml ) Need Help??


in reply to looping over multidimensional arrays

I read somewhere that if you are using counters in perl, you are not doing it right

That's probably a bit of an exaggeration to make a point: People coming from other languages will be used to C-style for loops, but often Perl's foreach will do away with a need to use indicies in the first place.

But sometimes you need an index, and there, instead of for (my $i; $i<@a; $i++), the more Perlish ways are for my $i (0..$#a) or, on newer versions of Perl, you can use each.

Note: This is a re-post of a node that was lost.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found