On Thu, 06 Jan 2011 21:31:11 -0500, Shawn H Corey wrote:
> On 11-01-06 09:25 PM, Parag Kalra wrote:
>> For example if I have a package say Foo::Bar. Now assume that there is
>> a object called $fob and pretend that I don't know that its an instance
>> of Foo::Bar
> 
> print ref( $fob ), "\n";
> 
> See `perldoc -f ref`.

The officially blessed :-) way to do this is with Scalar::Util:

use Scalar::Util qw(blessed);

say blessed( $fob );


since this can discriminate between a reference and a blessed reference.  
Consider the cases of

        $fob = {};
        $fob = bless {}, "HASH";

for instance.

-- 
Peter Scott
http://www.perlmedic.com/     http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl3/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to