Well, the (admittedly small) danger is that a call like &bar will pass on the current value of @_ to bar. That's almost never what you want. And even if it _is_ what you want, you'll confuse a maintenance programmer unless you write it as &bar(@_) (or bar(@_)).
#!/usr/bin/perl
sub foo {
&bar(1, 2, 3);
&bar; # silently passes on @_
}
sub bar {
print "@_\n";
}
&foo('a', 'b', 'c');
Also, in general, less punctuation is good - as the less there is to type, the less there is to get wrong :-)
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] [d/l] |
&NAME; # Makes current @_ visible to called subroutine.
and
A subroutine may be called using an explicit "&" prefix. The "&"
is optional in modern Perl, as are parentheses if the subroutine
has been predeclared. The "&" is not optional when just naming
the subroutine, such as when it's used as an argument to defined()
or undef(). Nor is it optional when you want to do an indirect
subroutine call with a subroutine name or reference using the
"&$subref()" or "&{$subref}()" constructs, although the "$subref->()" notation solves that problem. See perlref for more about
all that.
Subroutines may be called recursively. If a subroutine is called
using the "&" form, the argument list is optional, and if omitted,
no @_ array is set up for the subroutine: the @_ array at the time
of the call is visible to subroutine instead. This is an efficiency mechanism that new users may wish to avoid.
&foo(1,2,3); # pass three arguments
foo(1,2,3); # the same
foo(); # pass a null list
&foo(); # the same
&foo; # foo() get current args, like foo(@_) !!
foo; # like foo() IFF sub foo predeclared, else "
foo"
Not only does the "&" form make the argument list optional, it
also disables any prototype checking on arguments you do provide.
This is partly for historical reasons, and partly for having a
convenient way to cheat if you know what you're doing. See Prototypes below.
So, two points with '&' here: 1) propagates @_ implicitly, 2) bypasses prototype checking. If any of them is what you want, using '&' is fine; else not.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] [d/l] [select] |