in reply to shift vs. @_ (where @_ evaluates to 1)
First, you showed code (good), but you didn't actually show how the code was being invoked. In this particular case, the actual invocation wasn't relevant, though it often is. Posting a small, complete fragment increases the odds of getting problems solved.
Last, you can save space (and reader comprehension), by writing idiomatic Perl, like this:
instead ofsub getFoo { my($a, $b) = @_; my $strFoo = $a; ...
The former form maps arguments to lexical variables right away, which is friendly to your readers. Making people read further into your subroutine to find arguments increases the likelihood that people will misunderstand what you're doing.sub getFoo { my $a; my $b; my $strFoo; ($a,$b) = @_; $strFoo .= $a;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: shift vs. @_ (where @_ evaluates to 1)
by P0w3rK!d (Pilgrim) on May 09, 2003 at 18:46 UTC |