in reply to parameters
This is not a big problem if the number of entities in @fruit and @drinks is always the same, but suppose there are different amounts of fruit or drinks each time the script runs?my @fruit = ('apples', 'pears', 'bananas'); my @drinks = ('cola', 'lemonade', 'water'); foo(@fruit,@drinks);
This will print:foo(\@fruit,\@drinks); sub foo { my ($fruit,$drinks) = @_; print $fruit->[0], "\n"; print $drinks->[0], "\n"; }
|
|---|