- or download this
my %defaults = ref( $_[2+$[] ) ? %{$_[2+$[]} : {};
- or download this
sub routine
{
...
my $var = $_[1+$[]; # scalar
my %defaults = ref( $_[2+$[] ) ? %{$_[2+$[]} : {}; # optional hash
+ ref.
#blah...
- or download this
prompt> perl -we "print ref( undef() ) ? 'y' : 'n'"
n