in reply to Re (4): where do you put your subs
in thread where do you put your subs
I just wanted to point out that there is a side effect to not using parens on a subroutine/method call: the called subroutine "inherits" the @_ array of the caller.
Not entirely true. While &foo passes @_, foo and foo() and &foo() do not. Hence, imho for not passing @_ the best solution is to avoid the ampersand where possible (which means you pretty much only use it to create references).
Proof:
sub test { print "\@_: @_\n"; } @_ = qw(a b c); print 'test; # '; test; print '&test; # '; &test; print 'test(); # '; test(); print '&test(); # '; &test(); __END__ test; # @_: &test; # @_: a b c test(); # @_: &test(); # @_:
44696420796F7520732F2F2F65206F
7220756E7061636B3F202F6D736720
6D6521203A29202D2D204A75657264
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re (4): where do you put your subs
by demerphq (Chancellor) on Mar 12, 2002 at 13:23 UTC | |
Re: Re: Re (4): where do you put your subs
by mpeppler (Vicar) on Mar 08, 2002 at 21:17 UTC |