- or download this
foo(1,2,3,4);
sub foo {
my (@args) = @_; # now @args holds a _copy_ of all the arguments
}
- or download this
sub foo {
my $first = shift; # get the first argument and remove it from @_;
my $last = pop; # get the last argument and remove it from @_;
}
- or download this
my $i = 1;
inc($i);
sub inc {
$i++; #note: $i is not declared and read from @_
}
- or download this
my $i = 1;
inc($i);
...
my $i = shift; # declare and read $i from @_
$i++;
}