my $href = { a => 1, b => 2 }; my $scalar = 4; no warnings 'void'; if ( eval { %$href; 1 } ) { print "href is a href\n"; } if ( eval { %$scalar; 1 } ) { # This had better not print print "scalar is a href\n"; }