#!perl -w use strict; use warnings; use Data::Dumper; my @a = (1, 2, 3); my @b = (4, 5, 6); my @s = foo(@a, @b); print Dumper(\@a, \@b, \@s); sub foo { my ($t, $u) = (@_); # $t = 1 ; $u = 2 $u = undef; # $a[1] == 2 my $i = shift; # $i = 1 my $j = shift; # $j = 2 $_[0] = undef; # $a[2] = undef my $k = shift; # $k = undef $_[0] = undef; # $b[0] = undef my $x = $_[0]; # $x = undef $k = $i + $j; # $k = 1 + 2 ; $a[2] == undef $x = $i - $j; # $x = 1 - 2 ; $b[0] == undef my $y = shift; # $y = undef my @z = @_; # @z = [5, 6] $z[0] = undef; # @z = [undef, 6] ; $b[1] == 5 return $t,$u,$i,$j,$k,$x,$y,@z; } __END__ $VAR1 = [ 1, 2, undef ]; $VAR2 = [ undef, 5, 6 ]; $VAR3 = [ 1, undef, 1, 2, 3, -1, undef, undef, 6 ];