Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

To reinforce tobyink’s answer:

Is it the windows peculiarity which I have here?

No, with

use strict; use warnings; use diagnostics;

I get identical messages under cmd.exe (perl 5, version 16, subversion 0 (v5.16.0) built for MSWin32-x86-multi-thread-64int) and Cygwin (perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int):

$ perl -c 298_SoPW.pl Warning: Use of "-s" without parentheses is ambiguous at 298_SoPW.pl l +ine 36 (#1) (S ambiguous) You wrote a unary operator followed by something tha +t looks like a binary operator that could also have been interpreted + as a term or unary operator. For instance, if you know that the rand function has a default argument of 1.0, and you write rand + 5; you may THINK you wrote the same thing as rand() + 5; but in actual fact, you got rand(+5); So put in parentheses to say what you really mean. Unterminated <> operator at 298_SoPW.pl line 36 (#2) (F) The lexer saw a left angle bracket in a place where it was exp +ecting a term, so it's looking for the corresponding right angle bracket, + and not finding it. Chances are you left some needed parentheses out earlier in the line, and you really meant a "less than". Uncaught exception from user code: Unterminated <> operator at 298_SoPW.pl line 36. at 298_SoPW.pl line 36
If I search for files bigger than 1000 the parentheses are not necessary.

I take it you mean:

my @selection = grep { -s > 1000 } @ARGV;

Here there is no ambiguity, since > doesn’t begin any other operator, as < does.

Update: The following excerpt from -X may also be of (tangential) interest:

These operators are exempt from the "looks like a function rule" described above. That is, an opening parenthesis after the operator does not affect how much of the following code constitutes the argument. Put the opening parentheses before the operator to separate it from code that follows (this applies only to operators with higher precedence than unary operators, of course):

-s($file) + 1024 # probably wrong; same as -s($file + 1024) (-s $file) + 1024 # correct

Hope that helps,

Athanasius <°(((><contra mundum


In reply to Re: The "<" in the grep block by Athanasius
in thread The "<" in the grep block by vagabonding electron

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-19 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found