<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi folks,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Having read through the relevant parts of 'Programming Perl', 'Perl Best Practices' and PerlRefTut, I am still getting to grips with referencing and dereferencing, and I'm trying to formulate some conventions to make my code readable (or at least internally consistent). With this in mind, I've been trying to establish a 'one size fits all' way to pass variables into subs. I know that this might be inefficient for subs with only a couple of variables, but some of my subs need a dozen or so variables. Furthermore, I need to pass references. I'm going to be dealing with some arrays that are 7 million lines long, so I don't want to copy the arrays if I can help it. The data structures of the arrays are simple, its just that they are big.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>In following 'Perl Best Practices', I have set up the attached two versions of a 'conventional' program, which I intend to use as a kind of template for my 'real' program (its called PERRMOSS). They actually do what they are supposed to do, though I don't have the experience to fully explain why. I would be grateful for some sanity checking here.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If you've been reading my earlier posts, you will note that I'm not trying to use prototypes in these programs.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>A couple of questions;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Perl Best Practices says 'Use a hash of named arguments for any subroutine that has more than three parameters'. OK, that's PERRMOSS. I have varied the advice, though, in that I have set up a hash of references to the variables (because some of the arrays will be very big). This does seem rather convoluted because you've got to set up a hash with all the keys, then pass the hash to the sub, then look in all the keys in the sub to find what you're looking for. Does this approach make more defensive programming, or less? If the keys are to make sense, then they should have long names, like the names of the values, but then there's the danger of mixing up the key with the value.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Version 1 works well, but the syntax is cluttered because each operation has to derefence each variable at every step.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Version 2 attempts to get round this by dereferencing everything at the start of the sub. Does this mean it copies the variables in the sub?  Oddly, and I don't know why, if you hash out line 31, the sub applies the operation to the referent outside the sub, @k.  I thought that the referent would not change until you get to the end of the sub, which is what happens for $i, @j or %l. I take this as signifying that the code is not robust, so it is possibly not a good strategy to pursue.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks in advance for any help.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(Yes, I know the testprint line numbers in Version 2 are not accurate)</DIV><DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Regards,</DIV><DIV>Martin</DIV><DIV>Visit my website...</DIV><DIV><A href="http://web.mac.com/martin_jacobs1"><SPAN class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; ">http://web.mac.com/martin_jacobs1 </SPAN></A></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN></SPAN> </DIV></DIV></BODY></HTML>