in reply to the if statement
my %hash = (one => 'uno', two => 'dos', three => 'tres'); my $input = <STDIN>; chomp $input; if (my $ans = $hash{$input}) { print "$input => $ans\n"; }
Note that I've declared all the variables with my because I have strict (and warnings) enabled.
|
|---|