in reply to dynamically picking up Hashes or variables based on argument passed.
The best way is to use a hash:
my %temps = ( temp_2 => "foo", temp_3 => "bar" ); for my $i ( 2 .. 3 ) { print $temps{"temp_$i"}, "\n"; }
Notice that I changed your for loop into something a little more perlish.
untested: my Perl box broke :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dynamically picking up Hashes or variables based on argument passed.
by Anonymous Monk on Nov 19, 2007 at 22:48 UTC |