A concise description is in perlsub:
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.
Cheers, Sören
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|