Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


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.


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

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

In reply to Re: using 'my' by Elgon
in thread using 'my' by kiat

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2018-06-20 23:33 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (117 votes). Check out past polls.