Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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 ( [id://514684]=note: print w/replies, xml ) Need Help??


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

use overload '%{}'=>sub{{}}; sub new { bless [] } $ref = new(); eval { keys %$ref } ; print "is it a hash?" unless $@;

Replies are listed 'Best First'.
Re^3: Is there a way to find out what kind of ref an object is?
by diotalevi (Canon) on Dec 07, 2005 at 03:31 UTC
    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://514684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found