http://www.perlmonks.org?node_id=334104


in reply to Re: Can't grab $ARGV[n]
in thread Can't grab $ARGV[n]

If there were an error in scalar references, wouldn't the command window return some errors?

And about using strict, I've tried it in a handful of other scripts and when I run them I always get these Global symbol $whatever requires explicit package name errors when I use it. Two thirds of the time, when I take the use strict; line out, it works. This is why I never use strict, though I'm sure it would help me if i better understood it.

Replies are listed 'Best First'.
Re: Re: Re: Can't grab $ARGV[n]
by Gerard (Pilgrim) on Mar 05, 2004 at 03:55 UTC
    In when you are using strict you have to declare your varibles with the mykey word. ie my $foo = "a bar"; then when you use it later on you can just say $foo = "two bars";.
    The warning you are getting appears when the variables have not been declared in this way. This is helpful beacuse if you mis-spell a variable then you will be warned of the fact. This has saved me about 250,000 times from stupid typos and the like. There are other reasons too I am sure, but this is why I use it.

    Hope this helps.
Re: Re: Re: Can't grab $ARGV[n]
by runrig (Abbot) on Mar 05, 2004 at 19:02 UTC
    If there were an error in scalar references, wouldn't the command window return some errors?
    No, perl let's you use strings as numbers. If it can't figure out a numerical context for your variable, then the value assumed is zero.
    This is why I never use strict, though I'm sure it would help me if i better understood it.
    By all means, take the time to understand it. Start with what is further down in this thread, the Super Search I suggested earlier, and the documentation.

    Update: Another helpful link