exists $is_prime{$_} and $is_prime{$_} #### #!/usr/bin/perl use strict; use warnings; use feature qw/ say /; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my %hash; $hash{'A'} = 1; $hash{'B'} = 0; $hash{'C'} = -1; $hash{'D'} = undef; say Data::Dumper->Dump([\%hash], ['*hash']); for (qw/ A B C D E /) { say "Key: $_ Val: $hash{$_}"; say exists $hash{$_} ? ' exists' : ' does not exist'; say defined $hash{$_} ? ' defined' : ' not defined'; say $hash{$_} ? ' true' : ' false'; say '- -' x 20; } __END__