in reply to To be, or not to be, an object ?
Scalar::Util::blessed is the way to do this. If you're exceptionally paranoid, you have to check if it's defined, not merely true.
use Scalar::Util 'blessed'; my $oh_bee_jay = bless {}, '0'; print "not blessed\n" if not blessed $oh_bee_jay; print "defined blessed\n" if defined blessed $oh_bee_jay; __END__ not blessed defined blessed
I'd be surprised if this is an issue, though. Package '0' is not too popular.
|
|---|