Definitely overcomplicating it. Try this idiom: Think of a hash as a namespace, and its elements as variables within that namespace.
my @array = qw( Larry Curly Moe ); my %stooges; @stooges{ @array } = ( 0 .. $#array ); print "$_ = $stooges{$_}\n" for keys %stooges;
Or if you want numbers in the name:
%stooges = map { 'var' . $_ , $array[$_] } 0 .. $#array;
Dave
In reply to Re^3: Array loops and assignments
by davido
in thread Array loops and assignments
by madbee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |