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

the first thing that comes to mind is:
eval { keys %$ref } ; print "its a hash" unless $@;

Replies are listed 'Best First'.
Re^2: Is there a way to find out what kind of ref an object is?
by ysth (Canon) on Dec 07, 2005 at 00:10 UTC
    use overload '%{}'=>sub{{}}; sub new { bless [] } $ref = new(); eval { keys %$ref } ; print "is it a hash?" unless $@;
      That'd be the correct answer most of the time - if an object promises says it "can do" a hash interface, its up to everyone but the most sneaky to go by that.