Only, Perl has a well documented way to disambiguate this case.

If it does, it certainly doesn't say so in the documentation of print. This is the documentation of print (from 5.8.5):

       print FILEHANDLE LIST
       print LIST
       print   Prints a string or a list of strings.  Returns true if success-
               ful.  FILEHANDLE may be a scalar variable name, in which case
               the variable contains the name of or a reference to the file-
               handle, thus introducing one level of indirection.  (NOTE: If
               FILEHANDLE is a variable and the next token is a term, it may
               be misinterpreted as an operator unless you interpose a "+" or
               put parentheses around the arguments.)  If FILEHANDLE is omit-
               ted, prints by default to standard output (or to the last
               selected output channel--see "select").  If LIST is also omit-
               ted, prints $_ to the currently selected output channel.  To
               set the default output channel to something other than STDOUT
               use the select operation.  The current value of $, (if any) is
               printed between each LIST item.  The current value of "$\" (if
               any) is printed after the entire LIST has been printed.
               Because print takes a LIST, anything in the LIST is evaluated
               in list context, and any subroutine that you call will have one
               or more of its expressions evaluated in list context.  Also be
               careful not to follow the print keyword with a left parenthesis
               unless you want the corresponding right parenthesis to termi-
               nate the arguments to the print--interpose a "+" or put paren-
               theses around all the arguments.

               Note that if you're storing FILEHANDLES in an array or other
               expression, you will have to use a block returning its value
               instead:

                   print { $files[$i] } "stuff\n";
                   print { $OK ? STDOUT : STDERR } "stuff\n";

The only part that hints about ambiguaty is the part I boldfaced. But it doesn't explain at all why it parses the statement differently whether there's a space between the third and fourth token. Not that I expect most programmers to know what the phrase next token is a term means.


In reply to Re^3: Hidden Secrets of PERL by Anonymous Monk
in thread Hidden Secrets of PERL by perl_lover

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.