Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are not doing what you think you are doing. These two statements:</p> <pre><code>print none + 1 print 1 + none </code></pre> <p>Are not as straightforward as you might think. Because you have warnings turned off, you do not know what they do. Lets try them out in the command prompt, with warnings turned on (<code>-w</code> switch):</p> <pre><code>$ perl -lwe'print none + 1' Unquoted string "none" may clash with future reserved word at -e line 1. Name "main::none" used only once: possible typo at -e line 1. print() on unopened filehandle none at -e line 1. $ perl -lwe'print 1 + none' Unquoted string "none" may clash with future reserved word at -e line 1. Argument "none" isn't numeric in addition (+) at -e line 1. 1 </code></pre> <p>In the first case, <code>none</code>, which is a bareword, is interpreted as a file handle, and the print statement fails because we never opened a file handle with that name. In the second case, the bareword <code>none</code> is interpreted as a string, which gets converted to a number by the addition operator <code>+</code>, and that number will be zero <code>0</code>.</p> <p>You can further clarify this by supplying a specific file handle for the first case:</p> <pre><code>$ perl -lwe'print STDOUT none + 1' Unquoted string "none" may clash with future reserved word at -e line 1. Argument "none" isn't numeric in addition (+) at -e line 1. 1 </code></pre> <p>Which demonstrates that there is no real difference between <code>none + 1</code> and <code>1 + none</code>.</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. 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