Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

For development- or debugging-purpose I like to use something like the following piece of code:

# somewhere at the beginning of the code $SIG{__WARN__} = \&Warning; $SIG{__DIE__} = \&Die; # anywhere # ------------------------------------------------------------ sub Warning { my @text = @_; warn "------------------------------------------------------------ +\n"; warn "WARNING: @text\n"; my $count = 0; { my ($package, $filename, $line, $sub) = caller($count); last unless defined $line; warn sprintf("%02i %5i %-35s %-20s\n", $count++, $line, $sub, $filename); redo; } } # Warning # ------------------------------------------------------------ sub Die { my @text = @_; warn "------------------------------------------------------------ +\n"; warn "FATAL ERROR: @text\n"; my $count = 0; { my ($package, $filename, $line, $sub) = caller($count); last unless defined $line; warn sprintf("%02i %5i %-35s %-20s\n", $count++, $line, $sub, $filename); redo; } exit 1; } # Die # ------------------------------------------------------------

This installs "signal handlers" for die and warn which are executed every time when the functions die and warn are executed and print a backtrace on how the line the warning or die was produced was reached...

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

In reply to Re: Perl debug. How do I find calling line number? by strat
in thread Perl debug. How do I find calling line number? by brycen

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Corion]: marto: Oh, I'm jealous. I'm going to see DM in Frankfurt, but it's a stadium full of people, so, rather a big thing where you mostly get to see the band on screens ;)
    [marto]: yes, the last time I saw them was in Berlin a few years ago, at the old Olympic stadium

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (13)
    As of 2017-03-24 11:32 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (301 votes). Check out past polls.