Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

(zdog) Re: (2) Filling an array

by zdog (Priest)
on Sep 07, 2001 at 04:27 UTC ( #110804=note: print w/ replies, xml ) Need Help??

in reply to Re: Filling an array
in thread Filling an array

You can eliminate the $i var by doing the following:

for (0 .. $#array) { print "$_ $array[$_]\n" }

Also, I would think you'd be better off using one of the other suggestions like for() or the x operator rather than map() for efficiency reasons.

Zenon Zabinski | zdog |

Comment on (zdog) Re: (2) Filling an array
Select or Download Code
Replies are listed 'Best First'.
Re: (zdog) Re: (2) Filling an array
by spartan (Pilgrim) on Sep 10, 2001 at 19:50 UTC
    for (0 .. $#array) { print "$_ $array[$_]\n" }
    I like that... very clean, to the point, and quite readable. The only reason I chose map was to flex an all too atrophied brain muscle. :)

    Very funny Scotty... Now PLEASE beam down my PANTS!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-11-27 16:57 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls