What do the "use warnings;" and "use strict;" statement do exactly? So far I have noticed that when I try to use an uninitialized variable, it gives me a compilation error. That's NO BIG DEAL, I think. I mean, we're told in Perl tutorials, that we don't have to initialize variables in Perl. We can just start using them. Right? Just like in JavaScript or QBASIC.

So, WHAT EXACTLY HAPPENS IF I START USING UNINITIALIZED VARIABLES IN PERL? And why are people saying that we shouldn't get in the habit of doing this? In JavaScript, an uninitialized variable automatically becomes a global variable when we use it. So, if I refer to A in my function, then when I type "A = 5" it becomes a global variable. But if I initialize it as "var A = 5" then it becomes a temporary variable that exists only within the scope of that function. Is Perl treating variables the same way?

What else happens if I quit using the "warnings" and "strict"? Is there any other trouble that may arise? ARE MY PERL SCRIPTS GOING TO RUN SLIGHTLY FASTER IF I DON'T USE STRICT AND WARNINGS? I am just trying to think of all the pros and cons, but so far all I've heard is that you got to use these two. But I don't know why. I want to understand the whys.


In reply to Why use warnings? -w by harangzsolt33

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.