Manish Sapariya wrote:
Hi John,
Hello,
&printlist([EMAIL PROTECTED]);
^
You probably don't need the special behaviour that the ampersand
provides.
What special does '&' provide??
How do I find the exact help regarding this kind of usage in perldoc?
perldoc perlsub
[snip]
To call subroutines:
NAME(LIST); # & is optional with parentheses.
NAME LIST; # Parentheses optional if predeclared/imported.
&NAME(LIST); # Circumvent prototypes.
&NAME; # Makes current @_ visible to called subroutine.
[snip]
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.
[snip]
Constant Functions
Functions with a prototype of "()" are potential candidates for
inlining. If the result after optimization and constant folding is
either a constant or a lexically-scoped scalar which has no other
references, then it will be used in place of function calls made
without "&". Calls made using "&" are never inlined. (See constant.pm
for an easy way to declare most constants.)
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>