Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="http://perldoc.perl.org/perlop.html#Comma-Operator" rel="noreferrer">perlop</a>:</p> <blockquote> <p>The <code>=&gt;</code> operator is a synonym for the comma except that <strong>it causes its left operand to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores</strong>. </p> <p>This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behaviour, the left operand can be quoted explicitly.</p> <p>Otherwise, the => operator behaves exactly as the comma operator or list argument separator, according to context.</p> <p>For example:</p> <pre><code>use constant FOO =&gt; "something"; my %h = ( FOO =&gt; 23 ); </code></pre> <p>is equivalent to:</p> <pre><code>my %h = ("FOO", 23); </code></pre> <p>It is NOT:</p> <pre><code>my %h = ("something", 23); </code></pre> <p>The <code>=&gt;</code> operator is <strong>helpful in documenting the correspondence between keys and values in hashes, and other paired elements in lists</strong>.</p> <pre><code>%hash = ( $key =&gt; $value ); login( $username =&gt; $password ); </code></pre> </blockquote> <hr> <p>From <strong>PBP</strong>:</p> <p>I have found some good information from <strong>Perl Best Practices</strong> about <strong>Fat Commas</strong> <code>=&gt;</code> and i think it should be nice to mention over here too.</p> <p>It's better to reserve the fat comma exclusively for the following things:-</p> <p>Use it when <strong>constructing a hash</strong>:</p> <pre><code>my %h = ( FOO =&gt; 23 ); </code></pre> <p>or when passing <strong>named arguments to a subroutine</strong> ie.,</p> <pre><code>$text = format_text({FOO =&gt; 23, BAR =&gt; 30}); </code></pre> <p>or when <strong>creating a constant</strong>:</p> <pre><code> Readonly my $FOO =&gt; "23"; </code></pre> <p>For more detail see the Chapter4:Values and Expressions (Fat Commas) section of Perl Best Practices.</p>
    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.
    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