in reply to Is there a way to find out what kind of ref an object is?

It would be helpful to look at perlobj. The function that you are looking for is ref. Here is an example from perlobj, that shows what you are looking for:

$a = {}; $b = $a; bless $a, BLAH; print "\$b is a ", ref($b), "\n";

Replies are listed 'Best First'.
Re^2: Is there a way to find out what kind of ref an object is?
by jhourcle (Prior) on Dec 07, 2005 at 10:15 UTC

    Actually, ref doesn't give the underlying implementation. In the example code you gave, it should give 'BLAH', which doesn't tell you if 'BLAH' is an arrayref, or a hashref:

    for my $i ( [], {} ) { bless $i, 'BLAH'; printf( "%s\t%s\n", ref($i), $i ) }

    I typically use tye's answer, and go with UNIVERSAL::isa. (eg, if I'm dealing with structures passed in from a SOAP call, and I want to make sure the structure is right, even if the class name is wrong, before I start to manipulate it)