in reply to Re: Re: passing array as an argument
in thread passing array as an argument
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.
Well, that's not strictly true. Perl passes by reference by default. Consider:
Often people subvert this by copying the parameters themselves. Code like this is more common than not:perl -le 'sub scare { $_[0] = "boo!" } my $me; scare($me); print $me'
And usually, it's fine because argument lists aren't very big.sub foo { my @args = @_; # ... do stuff ... }
As for passing a single large array, though, there isn't much reason to pass a reference other than to be able to name it something nice in the sub rather than work directly with @_.
-sauoq "My two cents aren't worth a dime.";
|
|---|