Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'm sorry if I was not exactly precise. A more precise statement would have been "If the exception is not caught, then Perl itself prints it out which has the result of stringifying it. Hence it prints "Fart=ARRAY(0x...)", i.e. the default stringification of a blessed object, if you don't overload it and whatever you overloaded it to do otherwise. That's at least what I see on my machine with Debian Linux/Perl 5.10. Do you see something different?

Now, I hope you will not mind if I offer a slight clarification on your words.

When testing an exception, one cannot assume that it will be stringified. That depends on how one does the test, whether or not overload's "fallback" option is used, and what other operators are overloaded with a custom subroutine. For instance, if one tests by doing if (!$@) and you've overloaded !, then the overload for ! will be invoked, not stringification. If instead you do if ($@), then Perl will first look for an overload for "bool". If you have disabled fallback and you do not define the "bool", operator you will get a complaint "Operation 'bool': no method found". Only if you enable fallback, will it stringify the object to compensate for the missing bool operator definition. See overload for further discussion.

Also, just to be clear, in none of these cases (printing, testing) is the object itself destroyed. The application of the !, bool or "" operators are strictly for evaluation in context. The exception object remains an object before and after.


In reply to Re^4: Die silently? (/^but+$/) by ELISHEVA
in thread Die silently? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-28 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found