Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Passing Lists to Functions?

by mwah (Hermit)
on May 17, 2008 at 12:14 UTC ( [id://687082]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://687082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found