Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Think about Loose Coupling
 
PerlMonks  

Re^2: shift vs @_

by Argel (Prior)
on Oct 02, 2006 at 16:26 UTC ( [id://575949]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: shift vs @_
in thread shift vs @_

I'm not going to claim this is better but it does allow you to meet your change management goals while still using the my()=@_ form.
sub blah { my( $foo, $bar, $baz, ) = @_; }

Replies are listed 'Best First'.
Re^3: shift vs @_
by Argel (Prior) on Oct 02, 2006 at 16:39 UTC
    Actually, I think I will claim it is better. In theory it should be easier to notice changes since there is less clutter -- no leading "my" and no trailing "= shift" that someone eyeballing the code has to filter out so the variables themselves should stand out better.
      Perhaps, but consider the starting point of one argument:
      my( $foo, ) = @_;
      compared to:
      my $foo = shift;
      I use the shift approach because it gives me a clean starting point and lets me extend my methods (or subroutines) easily. Having said that, I try to avoid extending public methods and prefer to create new methods when appropriate. But perhaps I'm drifting away from the original question a little..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575949]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.