Thread (8 messages) flat view 8 messages, 3 authors, 2016-06-15

Re: [PATCH] Eliminate Scalar::Util usage from private-Error.pm

From: Randal L. Schwartz <hidden>
Date: 2016-06-15 22:42:33

quoted
quoted
quoted
quoted
"Petr" == Petr Baudis [off-list ref] writes:
Petr> We used just the blessed() routine so steal it from Scalar/Util.pm. ;-)
Petr> (Unfortunately, Scalar::Util is not bundled with older Perl versions.)

Wow.  That's sure the long way around for what I would use this for:

sub blessed {
        my $item = shift;
        local $@; # don't kill an outer $@
        ref $item and eval { $item->can('can') };
}

We call it "doing the can-can". :)

And this solution has the advantage that it doesn't pollute UNIVERSAL.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[off-list ref] <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help