Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How can I create an array that holds number of variables with values?

by Russ (Deacon)
on Dec 27, 2000 at 03:36 UTC ( [id://48368]=note: print w/replies, xml ) Need Help??


in reply to How can I create an array that holds number of variables with values?

Your question almost answers itself
my @var = (43, 60, 1..18); # Later... print $var[1], $var[14];
Use an array instead of multiple, distinct variables.

turnstep is right, you don't have to initialize all the variables to zero, just create them where you need them, giving a value at that time.

runrig's code (my @array = map {0} 0..19) works fine here, as well.

  • Comment on Re: How can I create an array that holds number of variables with values?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found