In article <[EMAIL PROTECTED]>, Tassilo Von Parseval wrote: [...] > If you from then on referred to elements of the hash with something like > > $score_ref->{ key }; > > then this would be it. It depends on what you want. By dereferencing the > whole data-structure you're essentially creating a copy. The downside of > that is that it needs more memory and is slightly less efficient. > However, that way your subroutine wont have side-effects. If you > directly work on the references, you'd change the hashes in your main > program (only on read-access, of course). That itself can be a valid > design decision. So it's up to you what you want.
Thanks, I know this question is very similar to one I posed not so long ago, but some concepts percolate in more slowly than others ("deep-watering" as they say in California). >> my $sort_hi if ($opt{h}); Ummm... a "digital artifact"? :-) > Ah, I should have read on. Either the unless or the else branch is the > last thing in your subroutine and so the last statement they evaluate is > returned. Hmmh, no. I wouldn't do it like that. It requires too much of > brain-power. ;-) What I often do in such a case is return early from a > sub and thus doing away with an else block. Like this: > > sub sort_results { > > my %scores = %{ (shift) }; > my %opt = %{ (shift) }; > > if (%opt) { > return sort { > compare($scores{ $a }, $scores{ $b }, $opt{ h }) > } keys %scores; > } > > return sort keys %scores; > > } > > First of all, I turned the logic around. What previously was the else > part is now the if part. I use an explicit return there. So the second > return statement is only reached when %opt was false. That makes good sense. I had originally added returns in there just to make it clearer, but your way looks even smoother. [...] > > The rest looks fine to me. However - and so turning back to your > original question - for this program you are probably best off by > directly working with the references. sort_results() would then look > like: Thanks! -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]