[prev] [index] [next]

Defining Functions (cont)

For functions with array or hash parameters

sub ff {
    my ($x, @y, %z) = @_;
    ...
}

Prototypes indicate expected parameter structure. Use one $ for each scalar and @ for a list.

Examples:

sub f($$$);
sub ff($@%);
or even
sub xyz(\[$@%]);

Perl check against the prototype provided it occurs before the first call on the function.

Put prototypes at the top of the file.