Reputation: 155
I have a hash like
%has = ('TCA' =>'S', 'TTC'=>'N'....)
and a
$string = 'TCA'
I want to look for my $string
in the %has
and if it exist, print the value using perl like this:
TCA, S
How can I do that? Thank you so much!
Upvotes: 1
Views: 74
Reputation: 67920
Check if the value exists.
if (exists $has{$string}) {
printf "%s, %s\n", $string, $has{$string};
}
Keep in mind that this is case sensitive.
You should probably read up on the various Perl functions in perldoc perlfunc
Upvotes: 3