in reply to Passing Reference of a Hash to a method

In,     my $hRef=@_; you're forcing @_ into scalar context, yielding count of its elements. As called, that is 1, and ref(1) gets you undef.

Fix this by making the assignment happen in list context:

sub traverseHash { my ($hRef) = @_; print ref($hRef); }

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Passing Reference of a Hash to a method
by bart (Canon) on Nov 23, 2004 at 11:53 UTC
    ref never returns undef. Even ref(undef) returns an empty string.
    local $\ = "\n"; print defined ref undef; print length ref undef;
    prints
    1
    0