Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Dynamic array names

by chromatic (Archbishop)
on Feb 09, 2001 at 23:16 UTC ( #57447=note: print w/replies, xml ) Need Help??


in reply to Dynamic array names

This is one of the Common Beginner Mistakes. (No offense, any experienced programmer who claims not to have asked the same question once is either Donald Knuth or a liar.)

If you have a list of items to process and you don't know how long the list will be at compile-time, use a stack. In Perl, that's as simple as using push to add another element to an array. That's exactly what arturo suggests.

Attempting to keep track of a bunch of names generated on the fly can be tricky, and in this case, it's probably completely unnecessary.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-09-23 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?