Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: User-Defined Sub, Passing a Single Argument?by kennethk (Abbot) |
on Oct 15, 2014 at 17:34 UTC ( [id://1103941]=note: print w/replies, xml ) | Need Help?? |
Note that Method #2 is buggy. You will not grab the argument, but the length of the argument array. You mean
so that the assignment is in list context. See Context in perldata. For my own work, I usually use unless I'm writing an object method, in which case I use shift to get the reference: though, if it's just a quick and dirty iterator over a list, sometimes I skip stripping the argument array entirely: See also Best Practices(TM) reference card, noting that it doesn't weigh in. #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In Section
Seekers of Perl Wisdom
|
|