in reply to •Re: blessed
in thread blessed

Funnily enough i was just coming back to put a link to that module into my description. Thanks. Also I just ran the full blessed.t from the Scalar::Util and both of my snippets pass all tests there (they arent that rigorous though, for instance no checks of qr// to be seen at all, nor blessed qr//'s)

Incidentally for the average Win32:: user this module isnt much help as it requires a compiler. (Oops, last time I checked ppm didnt have a version available, they do now.)

Nevertheless, for people who dont need all that Scalar::Util provides this will work just as well.

Cheers,

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

Replies are listed 'Best First'.
Re: Re: •Re: blessed
by jmcnamara (Monsignor) on Dec 05, 2002 at 16:38 UTC

    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.

      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....

Re: Re: •Re: blessed
by PodMaster (Abbot) on Dec 05, 2002 at 23:40 UTC
    That's why I opened up my repository. One PPM of Scalar::Util coming right up.

    http://crazyinsomniac.perlmonk.org/perl/ppm/Scalar-List-Utils.ppd

    update: I guess I ought to write PPM::Repositories or PPM::RepositoryList and release it on CPAN.


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.