Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

Cheers,
Paul


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://125234]
help
Chatterbox?
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: (7)
As of 2014-08-30 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls