http://www.perlmonks.org?node_id=195976


in reply to Re: Re: Style, style, style
in thread Style, style, style

What about my ($foo, $bar) = (shift, shift);?
Yuck.

Replies are listed 'Best First'.
Re: Re: Re: Re: Style, style, style
by belden (Friar) on Sep 08, 2002 at 18:02 UTC
    I regularly see one of these in a co-worker's code:

    sub blah { my ( $foo, $bar, $baz ) = ( shift, shift ); }

    Perhaps not too bad in a short list of shifts. But terrible when invoked as:

    shazam ( 0, 6, 7, $index, $arrayref, $hashref ); ... sub shazam { my ( $foo, $bar, $baz, $bup, $quz, $pig, $cow ) = (shift, shift, shi +ft, shift, shift, shift); }
    Quick, was $cow passed in via @_ or simply instantiated?

    update: added another egregious example, shazam

    blyman
    setenv EXINIT 'set noai ts=2'

      You might want to at least introduce your co-worker to the wonders of splice: my ($foo, $bar, $baz, $bup, $quz, $pig, $cow) = splice @_, 0, 6;

      Makeshifts last the longest.