in reply to Global Symbol issue while using arrays

When you take the time to type (or cut/paste) the phrase, "use strict;", or as someone else pointed out, "use Modern::Perl;", you are asking for Perl to enforce a number of rules that aim to improve your code's quality. The first rule is no symbolic references. The second rule is declare your variables. And the most common way to do that is to declare lexical variables, with "my".

I would encourage you to not put anything in your scripts that you don't know what function is being served. On the other hand, I would encourage you to put use strict; in every one of your scripts. Now we have an apparent contradiction: Don't include things you don't know what they do, and do use strict always. How to resolve that dichotomy? Read strict, Private Variables via my, and use, in that order. ;)

And as pointed out earlier, Modern::Perl is superset to strict.

....and as someone is sure to point out, rules are sometimes made to be broken.


Dave

Replies are listed 'Best First'.
Re^2: Global Symbol issue while using arrays
by prasaduco (Initiate) on Jun 07, 2011 at 07:12 UTC

    thanks davido, can u tell me where i can get info on -mdiagnostics (one rely asked me to do that). I googled around and could not find much info.

      Two places: -M is discussed in perlrun, and diagnostics.

      The -M causes Perl to invoke the module named immediately after the M. And diagnostics is a pragma that causes errors and warnings to become a lot more verbose (and presumably more helpful).


      Dave