I'd rather have two dozen shifts than a single goto. There's something almost assembler-like about that version of the goto statement. I've used it before, but only inside an AUTOLOAD. That's also only because in my opinion, AUTOLOAD is lacking some important functionality, like being able to return a subroutine reference that is automatically injected into the namespace to plug a hole. That, however, is another story.

Further, moving the @_ check to the front of the subroutine might not be viable. Or you could have something like this:
sub fooge { my ($foo, $bar, @baz) = @_; # ... if ($foo->isa('Acme::Frobnicator')) { die "Missing 'baz' parameter to fooge()\n" unless (@baz); $foo->frob(@baz); # ... } # ... }
You can do that with shift, sure, but it's not as concise.

Now regardless, I still can't see why using shift is better in any respect. Where do you draw the line? Four parameters? Five? And why draw the line at shift?
sub fooge { my ($foo, $bar) = (pop, pop); }
You'll note that shift is more verbose, and also permanently modifies @_. I'd rather have it there intact for debugging purposes. For example:
sub blarg { my ($foo, $bar, $bork) = @_; # ... if (computer_is_on_fire()) { die "Apocalyptic end of blarg(@_)\n"; } }

In reply to Re^6: Shifty Politics by tadman
in thread stoping and restarting a loop by mnlight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.