use strict;
use warnings;

my %hash = ('a' => 'b', 'c' => 'd');

sub check {
    my ($idx) = @_;
    if (defined $hash{$idx}) {
        print "$idx is defined";
    } else {
        print "$idx isn't defined" 
    }
}

check($hash{'a'});
check($hash{'x'});
check($hash{'b'});
   