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.
In reply to Re: the if statement
by FunkyMonk
in thread the if statement
by kwn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |