Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 avoiding work at the Monastery: (2)
As of 2016-02-06 03:27 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (215 votes), past polls