use strict; use warnings; my %h = (foo => 'oxen'); my $d = \%h; print test_it(), "\n"; sub test_it { return 1 if ( $d->{foo} && $d->{foo} =~ /X/i ); return 0; }