Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong><code>use strict; use warnings;</code></strong>. Always.</p> <p>Your hash declaration is not doing what you think it's doing, it has an odd number of elements.</p> <p>Try this:</p> <pre><code>use Data::Dumper; my %hash = ( 0=&gt; , 1=&gt;"Man"); print Dumper(%hash); </code></pre> <p>You'll see that <code>$hash{0}</code> is set to 1, <code>$hash{"Man"}</code> exists but is <code>undef</code>, and <code>$hash{1}</code> does not exist at all. i.e. your hash declaration is equivalent to:</p> <pre><code>my %hash = (0 =&gt; 1, "Man" =&gt; undef); </code></pre> <p><strong>Why</strong> is this happening? It's because:</p> <p><li> <code>=&gt;</code> is essentially an equivalent of <code>,</code><li> <a href="http://perldoc.perl.org/perldata.html#List-value-constructors" rel="nofollow">List value constructors</a> work that way, e.g. <code>($a,,$b)</code> is equivalent to <code>($a,$b)</code></p> <p>Relevant quotes from that document:</p> <blockquote> <p>The <strong><code>=&gt;</code></strong> operator is mostly just a more visually distinctive synonym for a comma, but it also arranges for its left-hand operand to be interpreted as a string if it's a bareword that would be a legal simple identifier. </p> </blockquote> <p>And:</p> <blockquote> <p>The null list is represented by <strong><code>()</code></strong>. Interpolating it in a list has no effect. Thus <strong><code>((),(),())</code></strong> is equivalent to <strong><code>()</code></strong>. Similarly, interpolating an array with no elements is the same as if no array had been interpolated at that point.</p> <p>(...)</p> <p>The list <strong><code>1,,3</code></strong> is a concatenation of two lists, <strong><code>1,</code></strong> and <strong><code>3</code></strong>, the first of which ends with that optional comma. <strong><code>1,,3</code></strong> is <strong><code>(1,),(3)</code></strong> is <strong><code>1,3</code></strong> (And similarly for <strong><code>1,,,3</code></strong> is <strong><code>(1,),(,),3</code></strong> is <strong><code>1,3</code></strong> and so on.) Not that we'd advise you to use this obfuscation.</p> </blockquote> <p>Apply this to your code:</p> <pre><code> (0 =&gt; , 1 =&gt; "Man"); is (0 , , 1 , "Man"); is (0 , 1 , "Man"); </code></pre>
    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