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.