Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
go ahead... be a heretic
 
PerlMonks  

Re: Is there a way to find out what kind of ref an object is?

by santonegro (Scribe)
on Dec 06, 2005 at 18:47 UTC ( [id://514676]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 06, 2005 at 19: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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://514676]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.