sub href_or_scalar { my $param = shift; my ($is_scalar, $is_hashref) = (0,0); if ( ! ref $param ) { $is_scalar = 1; } elsif ( ref $param eq 'HASH' ) { $is_hashref = 1; } else { die("I only accept a scalar or a HASHref!"); } print STDERR "'$param' is: (scalar => $is_scalar, hashref => $is_hashref)\n"; } href_or_scalar( 'hello!'); href_or_scalar( 'HASH' ); href_or_scalar( { key => 'value' } ); href_or_scalar( [ 'key' => 'value' ] ); __END__ 'hello!' is: ( scalar => 1, hashref => 0) 'HASH' is: ( scalar => 1, hashref => 0) 'HASH(0x225490)' is: ( scalar => 0, hashref => 1) I only accept a scalar or a HASHref! at c:\test.pl line 12.