in reply to Re: Does Semaphore Work?
in thread Safe Counter

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.