Using strict or warnings doesn't actually improve your script on its own, but it does stop you repeatedly making the most common mistakes. strict forces you to be more, well, strict about your code. For example, you have to localise your variables using local or my before you can use them. This means that you know for sure that you're not overwriting some other important variable that will be used later on in your script, and you're not going to do something with a variable that you assume has no value, but is really 3.14259 and causes seemingly random errors to come up. warnings is a little different, because it doesn't force you to do anything, but it does warn you about stuff that is possibly or probably an error.

Also, if you don't use warnings and strict, and you post something like "why is this failing?", when warnings or strict would have explained what's going on for you, you're probably not going to get much help. At least, you'll get told to use strict a lot. :-)


In reply to Re: Why use strict/warnings? by mischief
in thread Why use strict/warnings? by Mr.T

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.