My argument is simply that using
shift to extract several arguments is usually inefficient and, by induction, not very desirable:
my ($foo_a) = @_; # Simple
my $foo_a = shift; # Comparable
my ($foo_a) = (shift); # Odd
my ($foo_a, $foo_b) = @_; # Typical
my ($foo_a, $foo_b) = (shift, shift); # Odder
my ($foo_a, $foo_b, $foo_c, $foo_d) = @_;
my ($foo_a, $foo_b, $foo_c, $foo_d) = (shift, shift, shift, shift);
The last one is, I hope you'll agree, outrageous, and is best reserved for those sitations where you'd explain it, but it's a "long story".
I'm not saying that you shouldn't use
shift. You can program any way you like. You can also use
goto with impunity, variable names that make no sense, and use
substr and
unpack instead of regular expressions. What I'm suggesting is that using multiple
shifts in a function is poor form and is a bad habit to develop.
Oh, and a
goto by any other name still smells as rotten. I'd like to see any
Benchmark that could show that using that technique you describe could provide measurable performance gains. As far as I can tell, passing the whole args array is fairly efficient. Pulling them apart and repacking them isn't.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.