Another thing is that, for performance reason, even there is only one parameter, it is still a good idea to pass array ref, instead of array.
(davido didn't mention this simply because this was not asked in the original post)
my @numb = (1..100); print sum(\@numb); sub sum { my $numb = shift; my $total; foreach (@$numb) {$total += $_}; return $total; }
In reply to Re: Re: passing array as an argument
by pg
in thread passing array as an argument
by podian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |