It will only accept a single scalar.
Not quite. It accepts a single argument and evaluates it in scalar context. Thus a subroutine prototyped with ($) will accept an array as an argument (and since it's in scalar context, you dutifully get the number of elements in the array in $_[0]). Examples:
sub foo ($$) { ... }
foo($a); # invalid, not enough args
foo(@a); # invalid, not enough args
foo($a,$b); # valid
foo(@a,@b); # valid
foo($a,@b); # valid
foo(@a,$b); # valid $_[0] gets the number of elements in @a
That last one tends to disturb those people that are used to perl flattening of arrays into lists but aren't used to perl's prototypes.
|