http://qs321.pair.com?node_id=687082


in reply to Passing Lists to Functions?

The most significant error (shift as a sub) has been already mentioned. (Put a large 'S' as the first char if you need to name it that way).

I'd like to make a comment to other aspects of your code. If you give a reference to something into a sub, this (referenced) object will be modified, so you won't need to copy it back and forth.

... # the array will be modified 'in place', so theres # no necessity to copy stuff around Shift( \@reduced_protein, $x2-$x1, $y2-$y1, $z2-$z1 ); ... sub Shift { my ($rp_ref, $x, $y, $z) = @_; # traditional way to feed a sub my $index1; # the expression @$array_ref expands a reference to a list my $protein_length = findColumnLength(@$rp_ref); for (shifting operation) { ... # instead of: $reduced_protein[i], # you say: $rp_ref->[i] ... } # no need to return anything, the original array is # already modified }

Regards

mwa