in reply to passing whole array to a function

Perl's passing of arrays and hashes is a little different from most other languages. So when you pass in an array @a to a subroutine, @_ will have (@#a +1 ) arguments. Essentially, it just unrolled the array for you.

To achieve what you are trying to do, pass in references to the arrays. You can then use the references in your subroutine or dereference them into arrays if you prefer.

use strict; use warnings; sub passingArray{ my $tmp = $_[0]; my $newtmp = $_[1]; print "Number of elements tmp: ". scalar( @$tmp ) . "\n"; print join( " ", @$tmp ) . "\n"; print "Number of elements newtmp: ". scalar( @$newtmp) . "\n"; print join( " ", @$newtmp) . "\n"; } #end of sub my @data = ( 22, 33, 44 ); my @newdata = ( 55, 66, 77 ); passingArray( \@data, \@newdata );

Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd