my %colors = ( "1" => "blue", "2" => "green", ); my $COLOR = 2; # 1..2 sub geth { print "$colors{$COLOR}\n"; } geth(); #### my @colors = ( "blue", "green", ); my $COLOR = 1; # 0..1 sub geth { print "$colors[$COLOR]\n"; } geth();