Passing array to a subroutine
#!/usr/bin/perl -w
use strict;
my(@nums1, @nums2);
@nums1 = (2, 4, 6);
@nums2 = (8, 10, 12);
process_arrays(@nums1, @nums2);
sub process_arrays {
my(@a, @b) = @_;
print "contents of \@a\n";
print "[$_] " foreach @a;
print "contents of \@b\n";
print "[$_] " foreach @b;
}
Related examples in the same category