in reply to To be, or not to be, an object ?

Thanx both for your quick responses.

I know about Scalar::Util but hadn't even considered it - doh!! Having had a peek @ the code, AFAICT, it does something extremely similar - I'm now rather worried I might be gaining a little understanding ... looks somewhat worried

Mmm, Autobox - what a thing that is ?! I'll try my approach with it and see ... might even let you know the results :-))

Update

There are, 2 aspects to the differences between my attempt and Grahams' (author of Scalar::Util), Graham...

Whereas I use the (now standard) isa() method and omitted the call to ref - since the call to isa() would, methinx, generate either a 'not an object' or 'not an reference' error - aka a short cut.

At last, a user level that overstates my experience :-))

Replies are listed 'Best First'.
Re^2: To be, or not to be, an object ?
by betterworld (Curate) on Jul 24, 2008 at 14:30 UTC
    There are, 2 aspects to the differences between my attempt and Grahams' (author of Scalar::Util), Graham...
    • creates a temporary method in the UNIVERSAL class

    Scalar::Util uses UNIVERSAL::a_sub_not_likely_to_be_here, but it's not a temporary method, because (unless I'm mistaken) it stays in the UNIVERSAL namespace forever.

    However, the XS version of Scalar::Util is pretty straightforward, it's blessed() does not use any dirty tricks at all, it just determines whether something is blessed, using the appropriate API.

      TFT, point taken.

      I would point out that temporary and forever are one and the same in this context i.e. the lifetime of the program useing Scalar::Utils.

      At last, a user level that overstates my experience :-))