Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The dollar sign here is a sigil that indicates that the named variable is a scalar.</p> <p>If there is no preceding <code>package</code> declaration, the use of <code>$var_name</code> contains an implied namespace of <code>main</code>, i.e. it is short for <code>$main::var_name</code>. In the case of your example, where you have <code>package main;</code> first, you need to stipulate that the namespace is <code>test</code>, rather than <code>main</code>, so <code>$test::testVar</code> is required.</p> <p>For a function call, you do not need to use a sigil. If you did, you would use the ampersand (<code>&amp;</code>), but using ampersands when calling functions has fallen out of favour with many programmers.*</p> <p>As before, <code>sub_name()</code> is a shortened version of <code>main::sub_name()</code>... in the same way, no sigil is needed to call <code>package::sub()</code>.</p> <p>*References as to the use of <code>&amp;</code>:</p> <ul> <li><a href="http://www.perlmonks.org/?node_id=428024" rel="nofollow">Perl Monks discussion</a></li> <li><a href="http://kobesearch.cpan.org/htdocs/Perl-Critic/Perl/Critic/Policy/Subroutines/ProhibitAmpersandSigils.pm.html" rel="nofollow">Perl::Critic</a> dislikes it, following on from <a href="http://oreilly.com/catalog/9780596001735" rel="nofollow">Perl Best Practices</a></li> <li>Per <a href="http://perldoc.perl.org/perlsub.html" rel="nofollow">perldoc</a>, using <code>&amp;</code> with a function name allows you to deviate from the <strong>usual</strong> behaviour. This can result in subtle bugs.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload