Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: looping over multidimensional arrays

by haukex (Chancellor)
on Sep 23, 2018 at 08:02 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-01-23 03:10 GMT
Find Nodes?
    Voting Booth?