Function definition: Difference between revisions

m
(→‎{{header|TXR}}: Explicit -B to show variable bindings.)
Line 1,228:
The above subroutine can only be called with exactly two [http://perldoc.perl.org/perldata.html#Scalar-values scalar values] (two dollar signs in the signature) but those values may be not numbers or not even defined. The <code>@_</code> array is unpacked into <code>$a</code> and <code>$b</code> lexical variables, which are used later.
 
The arguments can be automatically unpacked into lexical variables using the [http://search.cpan.org/perldoc?signaturesexperimental signatures] modulefeature (in core as of 5.20):
<lang perl>use experimental 'signatures';
sub multiply ($x, $y) {
return $x * $y;
Anonymous user