perl file test operators and "$_" -


i'm going through o'reilly's "intermediate perl". -s used so:

print map { "    $_\n" } grep { -s < 1000 } @argv; 

which gives warning:

warning: use of "-s" without parentheses ambiguous unterminated <> operator

though, when put parentheses around -s works charm. not sure if perl version related or mistype authors.

perl version: v5.18.2 built darwin-thread-multi-2level

what causing issue , can correct it?

< can start of term readline/glob shortcut.

print "[$_]\n" < b c >; 

< can start of infix operator numeric less-than operator.

print "foo\n" if $x < 3; 

-s can legally followed both, perl has guess 1 wanted when sees <. using of following instead of -s solves issue since none of them can followed term:

  • -s($_)
  • -s()
  • (-s)

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -