Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Problem w/overloading and Carp::confess

by pjf (Curate)
on Nov 14, 2001 at 07:36 UTC ( #125234=note: print w/ replies, xml ) Need Help??

in reply to Problem w/overloading and Carp::confess

The problem here, as you no doubt guessed, is that somewhere in the guts of Carp we attempt to stringify your object again, kicking off the asString method (yet again) to try and do this.

The solution here is to detect when that's happened and return a static string, rather than calling confess again. Here's an example:

sub asString { return __PACKAGE__ if (caller)[1] =~ /Carp/; confess; }

That nicely breaks the recursion. Discovering why Carp is trying to stringify your object is left as an exercise for the reader. ;)


Comment on Re: Problem w/overloading and Carp::confess
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://125234]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-08-30 18:03 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (350 votes), past polls