if ( ref($ref) eq 'HASH') { # return the elements as list. No real practical value other # than as an exercise.. at least as much as I can see return 'ref to HASH', values %$ref; } elsif (ref($ref) eq 'ARRAY') { # return the elements as a list return 'ref to ARRAY', @$ref; } elsif (ref($ref) eq 'SCALAR') { return 'ref to SCALAR', $$ref; } elsif ( not ref($ref)) { return 'not a ref'; } # and so on.. }