Reputation: 43
I'm going through O'Reilly's "Intermediate Perl". -s
is used as so:
print map { " $_\n" } grep { -s < 1000 } @ARGV;
which gives this warning:
Warning: Use of "-s" without parentheses is ambiguous Unterminated <> operator
Though, when I put parentheses around -s
it works like a charm.
Not sure if this is perl version related or a mistype by authors.
Perl version: v5.18.2 built for darwin-thread-multi-2level
What is causing this issue and what I can do to correct it?
Upvotes: 1
Views: 206
Reputation: 385635
<
can be the start of a term as the readline
/glob
shortcut.
print "[$_]\n" for < a b c >;
<
can be the start of an infix operator as the numeric less-than operator.
print "foo\n" if $x < 3;
-s
can legally be followed by both, so Perl has to guess which one you wanted when it sees the <
. Using any of the following instead of -s
solves the issue since none of them can be followed by a term:
-s($_)
-s()
(-s)
Upvotes: 2