Working on a largish project, I have a ton of info to STDERR for watching what's up while the program is running.

I would have some errors and then it was tough to find them back in the code- I had a mountain of info on my error log. (using tail -f has been glorious)

For example, I know my sub will need scalar $a to hold a digit, if it doesn't- then I would normally output an error to STDERR, I felt that die was more holy, only for things that the system or perl would recognize as a real 'you are deadw, monkey' error.

lately, I realized that I should use die() a lot..?

1) Does this seem like it would help debugging, use die *whenever* something happens that should not happen? Is this a no brainer? What do other people do?

2) I've heard here and there that subs and scripts should ideally output nothing unless there's an error, is there any controversy to this amongst more experiences coders? Or is this basic mattured wisdom?


In reply to when to use die, questions about program feedback to the coder by leocharre

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.