Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Can't grab $ARGV[n]

by OxYgEn (Acolyte)
on Mar 05, 2004 at 02:48 UTC ( #334104=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Re: Can't grab $ARGV[n]
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 my key 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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-09-02 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls