in reply to Why reftype and blessed are making my life harder than it needs to be
Your conversion doesn't really have equivalent semantics. isa includes subclass relationships, which you won't get with ref or blessed.
In the example you gave, what's wrong with this (assuming you don't really want @ISA semantics):
my $is_blah = ref( $thing ) eq 'Some::Class' && $x == 3;
I tend to think of blessed as a boolean -- not a replacement for ref (excepting if blessing into the empty string is something to check for).
And while it's a bit verbose, you could tackle the reftype bit this way:
my $r = ref( $value ) && reftype( $value );
That doesn't really gain you much over reftype( $value ) || q{} except maybe a moment's less thought for the next reader about why the empty string is the alternative if reftype is false.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|