To expand a little on what Zaxo said...

Perl generaly tries to be a very helpful language. By default, it lets you write some strings without quoting them, simply by saying something like print string;. Unfornatly, there's no way to tell this apart from something that you meant to be a function, but never defined, and called without parenthesies. That is, when you write print foo;, you may have meant print "foo";, or you may have meant print foo();. By default, perl thinks you meant the second if a subroutine named foo actualy exists, and the first if there is no such subroutine.

However, this can often create difficult-to-debug problems, and isn't really that helpful in the first place (typing the quotes isn't that hard, and makes your code easier to read). Thus, putting a use strict; at the beginning of your code disables this feature -- print foo; means to run the sub named foo, and print the result. If there is no sub named foo defined when the code is run, then it's an error.

(use strict also changes other things that make it more difficult to cause yourself problems -- it makes you declare your variables, and it keeps you from talking about variables by name when what you really meant was to refer to them -- don't worry about that last. use warnings, on the other hand, warns you when what you said is most likely not what you meant.

Using both of them, as a matter of habit, will make it more obvious when you're messing up, and how, so you can help yourself.


In reply to Re: Re: Does Semaphore Work? by theorbtwo
in thread Safe Counter by Gorby

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.