Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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


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 having an uproarious good time at the Monastery: (3)
As of 2016-10-23 00:39 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (299 votes). Check out past polls.