Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Specifiying a Range for Variables?

by joealba (Hermit)
on Nov 27, 2002 at 17:20 UTC ( [id://216120]=note: print w/replies, xml ) Need Help??


in reply to Specifiying a Range for Variables?

Here's one way.
$cmd1 = 'This'; $cmd2 = 'Is'; $cmd3 = 'a'; $cmd4 = 'test'; my @cmds = map {${"cmd$_"}} (1..4); for (@cmds){ print "$_\n"; }
I'll refrain from the obligatory "You should use a hash instead..." statement on the assumption that this is simply a learning exercise. :)

Replies are listed 'Best First'.
Re^2: Specifiying a Range for Variables?
by Aristotle (Chancellor) on Nov 27, 2002 at 17:36 UTC

    Why? Well if you won't, then I shall. :)

    - That should be a hash.

    Further materials: Dominus' archived newsposts, part one, two and three on Why it's stupid to 'use a variable as a variable name'.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found