programming-examples/perl/Subroutine/Passing array to a subroutine.pl
2019-11-15 12:59:38 +01:00

20 lines
316 B
Perl

#!/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;
}