in reply to using arrays of arrays

Your problem here is that you're taking a reference to the array and then dereferencing it in the subroutine getting back the original array.

Instead of

my $myarrayref = \@myarray;

try doing

my $myarrayref = [@myarray];

Take a look at perlref for a discussion of how this works; if that seems a little advanced for you, try the tutorial: perlreftut.

-- Ken