in reply to Re: How to handle passed data in subroutines
in thread How to handle passed data in subroutines

BTW, you normally should pass array ref, not array, to your subs, for performance reason.

I consider this misguided advice.

I think that people normally should pass whatever is clearest, and consider performance a distinctly secondary concern. This chapter is timeless and applicable across languages.

Sure, this isn't always true. Occasionally you really do need to squeeze performance and straightforward good architecture choices, a bit of tuning bottlenecks, etc won't get you there. But in those problems, Perl is probably the wrong language to use in the first place.

OTOH I agree with you when you say, Also, if you pass multiple arrays, or array mixed with other stuffs, you can easily lose track of the boundary of your array. However whether I think that this means that you should pass things into functions by reference depends on what the function does.

  • Comment on Re: Re: How to handle passed data in subroutines