http://qs1969.pair.com?node_id=616780


in reply to calling subs using references.

I have a niggle. There's a misquoted idiom in your constructor. The line is:

return bless {}, $caller || ref($caller);

If $caller is false, there's no way it can be a reference. The idiom you've misquoted has the or round the other way, which allows the user to pass in an existing object from which you derive the package name.

In practice, nobody's ever going to call new on an existing object. There's thus no need to document and test for this special case, just code it as:

return bless {}, $caller;

--
wetware hacker
(Qualified NLP Practitioner and Hypnotherapist)