I found myself using cluck() today. Nothing wrong about that, except I couldn't find a nice way to ditch it for perl -d. I'm trying to see how to schedule/stop for a stack trace in this situation, with the debugger:
sub message_id($) { my $tr = shift; defined $tr or cluck(), return undef; $tr->isa('HTML::Element') or return undef; my $td = ($tr->content_list())[0]; return $td->as_trimmed_text(); }
This function is called hundreds of times, I only want a backtrace when it's about to return in that specific condition.
(and yeah, I know cluck works perfectly there).

Thanks in advance


In reply to Translate debug code to a debugging technique by hlen

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.