in reply to Why does NOT operator on match operator on string concatenation require two pairs of parens?
Parens break precedence!
In this case Perl sees an opening bracket for the operand of the not operator.
(emphasis added)
"A TERM has the highest precedence in Perl. They include variables, quote and quote-like operators, any expression in parentheses, and any function whose arguments are parenthesized. Actually, there aren't really functions in this sense, just list operators and unary operators behaving as functions because you put parentheses around the arguments. These are all documented in perlfunc"
"Any function in the list below may be used either with or without parentheses around its arguments. (The syntax descriptions omit the parentheses.) If you use parentheses, the simple but occasionally surprising rule is this: It looks like a function, therefore it is a function, and precedence doesn't matter. Otherwise it's a list operator or unary operator, and precedence does matter."
If you're confused what Perl is parsing, using B::Deparse can come in handy.
$ perl -MO=Deparse -e' (not ($label.$inst) =~ /\blea\b/i)' !($label . $inst) =~ /\blea\b/i; -e syntax OK ~ $ ~ $ perl -MO=Deparse,-p -e' (not ($label.$inst) =~ /\blea\b/i)' ((!($label . $inst)) =~ /\blea\b/i); -e syntax OK ~ $
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|