in reply to Re: •Re: blessed
in thread blessed


Incidentally for the average Win32:: user this module isnt much help as it requires a compiler.

Scalar::Util also contains pure Perl versions of the functions for systems without a C compiler. Here is the Perl version of blessed() directly from the source:

# The code beyond here is only used if the XS is not installed # Hope nobody defines a sub by this name sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) } sub blessed ($) { local($@, $SIG{__DIE__}, $SIG{__WARN__}); length(ref($_[0])) ? eval { $_[0]->a_sub_not_likely_to_be_here } : undef }

--
John.

Replies are listed 'Best First'.
Re: Re: Re: •Re: blessed
by demerphq (Chancellor) on Dec 05, 2002 at 20:26 UTC
    Yep.

    And its about 2 1/2 times faster too. :-) Looks like overload::StrVal is pretty slow.

    The approach that I use above does have one advantage however. It doesnt pollute UNIVERSAL. Actually there is another as well, while not applicable to this situation, it also allows determining the underlying type in one call. But Scalar::Util provides a way to do that too (i havent benchmarked the two calls against the one however).

    Well, at least this thread shows a couple of ways to do it. :-)

    Thanks for the reply.

    --- demerphq
    my friends call me, usually because I'm late....