in reply to Using & in function calls
1. using &subname; without braces does not do what you probably think it does. It passes the current value of @_ to the called sub - and subname() update: or subname; does not.
2. when you're passing arguments, most of the time the you are either using braces and/or the subroutine has already been defined, and in both cases the & is not needed. Also strict will warn you if it gets confused in this case. Basically, not using "&" will save you typing.
The only times I use &subname is when a) I want to create a reference to a named subroutine (which is fairly rare), or b) I want to do goto &subname; (which is an even more rare, but does have its uses in that it's the only way to "fake tailrecursion" in perl - see goto)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using & in function calls
by demerphq (Chancellor) on Oct 02, 2007 at 08:30 UTC | |
by Joost (Canon) on Oct 02, 2007 at 21:12 UTC |