in reply to Re: What's the better Perl style? Define parameters or not?
in thread What's the better Perl style? Define parameters or not?
Gives:sub mysub($@\%) { my ($one, @two, $ref) = @_; print "@two\n"; } mysub('a','b','c','d');
The minimum length of a list is zero elements, so the following "works" (in that no error is reported) as well:b c d
If you want to force an array, use \@. Prototypes are useful for forcing the correct type of reference being passed at compile-time (as opposed to runtime checks) but are so easy to circumvent, even accidently, that they can lull you into a false sense of security.mysub('a');
|
|---|