#!/usr/bin/perl -w use strict; randarrays(); # Sub to create two arrays with 5 random elements sub randarrays { my (@a1,@a2) = (); push @a1, (int rand 1000) for (1..5); push @a2, (int rand 1000) for (1..5); printarray(\@a1,\@a2); # \@ makes the call pass by reference. } # print the arrays sub printarray { my ($array1_ref, $array2_ref) = @_; # read the refrences into scalars print "array 1\n"; print +($_,$/) for (@{$array1_ref}); # @$ derefrences print $/; print "array 2\n"; print +($_,$/) for (@{$array2_ref}); }