Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
No lecture on strict is complete without MJD's summary of what it does:
  1. It enables strict 'refs', which prevents strings from being accidentally used as references. None of the examples in the book used references at all, so there was no reason to use strict 'refs'.
  2. It enables strict 'vars', which prevents global variables from being used without being declared; typically, one declares variables local with the my declaration. While this is good practice in general, the example programs were all very small---less than twenty lines each. In such small programs, there is no practical difference between a global variable and one that has been declared with my. No benefit would have accrued from requiring the use of my declarations of every variable.
  3. It enables strict 'subs', which is of very limited value even at the best of times. strict 'subs' forbids unquoted strings, because such strings ('barewords') can cause long-term maintenance problems. If you have code like
  4. if ($x eq carrots) { ... }

    the carrots is taken as a literal string. But if someone later adds a carrots() function to the program, the meaning of this line might change suddenly and unexpectedly, to call carrots() and compare $x with the returned value. This is not too likely, except perhaps in very large and long-lived programs, which is why strict 'subs' is of such limited value. In 20-line book examples, it is of no value whatsoever.


In reply to Re: RFC: Tutorial: use strict; now what!? by educated_foo
in thread RFC: Tutorial: use strict; now what!? by Xiong

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (8)
    As of 2014-07-13 17:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (251 votes), past polls