in reply to Re^2: Hash value interpolation
in thread Hash value interpolation
my %colors = ( "1" => "blue", "2" => "green", ); my $COLOR = 2; # 1..2 sub geth { print "$colors{$COLOR}\n"; } geth();
Or why you aren't using an array.
my @colors = ( "blue", "green", ); my $COLOR = 1; # 0..1 sub geth { print "$colors[$COLOR]\n"; } geth();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Hash value interpolation
by csarid (Sexton) on Feb 17, 2009 at 22:44 UTC | |
by ikegami (Patriarch) on Feb 17, 2009 at 23:01 UTC | |
by csarid (Sexton) on Feb 18, 2009 at 05:14 UTC |