in reply to stringified references
Heres a more rigourous definition of a is_blessed test.
Incidentally for this check its faster but less idiomatic to say$is_blessed = defined($x) && ref($x) && overload::StrVal($x) =~ /=/;
BTW, only if you choose to consider qr// constructs to be blessed then this test is fine. If you dont then you need something like$is_blessd=defined($x) && ref($x) && (index(overload::StrVal($x),'=')> +=0);
PS: Im hoping that its obvious that you have to use overload; for all of this.$is_blessd=defined($x) && ref($x) && (index(overload::StrVal($x),'=')> +=0) && overload::StrVal($x)!~/^Regexp=SCALAR/;
Cheers,
update:* I didnt mean to imply that he was wrong about the Scalar::Util approach. However it is an extra module and the code I mention should be fine without it. Although it is a lot faster to use than all of the above.
--- demerphq
my friends call me, usually because I'm late....
|
|---|