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.
In reply to Re: Scoping Issue
by BrowserUk
in thread Scoping Issue
by webdorx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |