Hope this helps,#!/usr/bin/perl -w use strict; # define some arrays my @array1 = qw/apple orange/; my @array2 = qw/pear strawberry/; # call the subroutine passing references to arrays &showFruits(\@array1, \@array2); sub showFruits { # get the array references my ($array1_ref, $array2_ref) = @_; # use the array references to get to arrays foreach my $f1 (@$array1_ref) { print "$f1\n"; } foreach my $f2 (@$array2_ref) { print "$f2\n"; } }
In reply to Re: passing arrays to asubroutine
by emilford
in thread passing arrays to asubroutine
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |