Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: using 'my'

by Elgon (Curate)
on Jun 21, 2001 at 19:21 UTC ( #90404=note: print w/ replies, xml ) Need Help??


in reply to using 'my'

Kiat,

Fret ye not: This is not a lame question but rather relates to an article of the faith for Perlmonks.

The strict answer to your question (excuse the bad pun) is no, you do not need to declare the variables if you are not using the strict pragma. This means you will need to declare all of your variables using my which is generally agreed to be a good idea.

A slightly better answer is that you should (nearly) always use strict; and preferably the -w switch or the warnings pragma too (These two are very slightly different if you're using Perl 5.6 or later, see this for more info.) If there is a good reason why you shouldn't be using strict there is probably a far better and/or safer way of doing what you are trying to do!

There are lots of very good reasons why you should use strict; and warnings and if you are doing CGI work -T too: You will be warned about typos in your variable names because the code won't run and will give you the location of the (probable) typo, warnings will give you more useful debugging information about nonfatal errors in your code and -T, well let's just say that it can make life a more pleasant experience for everybody except anyone trying to do unpleasant things to your website. All of the links given by the other posters will be damned helpful, good luck.

Elgon

PS: Oh, and welcome to <a href="http://"www.perlmonks.org">Perlmonks!

"Without evil there can be no good, so it must be good to be evil sometimes.
--Satan, South Park: Bigger, Longer, Uncut.


Comment on Re: using 'my'
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://90404]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-09-22 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls