in reply to Scoping Issue
The problem is the empty set of parens in your sub declaration.
sub valid_req() { # ^^
In perl, that is called an empty prototype, and it basically says "This sub never takes any arguments". Which means that
@command = (@_);
will always result in @command being empty, regardless of what you try to pass in when calling the sub.
If you had strict & warnings* enabled, then you would have been informed of your error with the message
Too many arguments for main::valid_req at ...
The short term answer is to remove the parens completely, and never use a prototype in perl unless you know that you need to.
The better, long term, answer is to make the transition to using strict and warnings* in your code. It only takes a little while to get used to the few easy steps required to satisfy them.
It just makes life easier.
*References to the warnings pragma added after ambrus's correction below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Scoping Issue
by ambrus (Abbot) on May 16, 2004 at 19:18 UTC | |
by BrowserUk (Patriarch) on May 16, 2004 at 19:23 UTC | |
|
Re: Re: Scoping Issue
by Errto (Vicar) on May 16, 2004 at 23:24 UTC | |
by castaway (Parson) on May 17, 2004 at 05:17 UTC | |
by webdorx (Initiate) on May 26, 2004 at 11:03 UTC |