in reply to Re^2: map sentence with subtraction interpreted as with negative number
in thread map sentence with subtraction interpreted as with negative number
Well, I said I found your first case confusing, I think this one is worse, it took me far too much time to understand what you meant to do. But the main difference is that the previous example at least was a plain old syntax error, caught at compile time. This one is valid syntax:
This makes it even trickier as it might be seen too late. And this means you can't say that you can guess that an operator is not unary when there is a scalar on its left, because perl actually allows this kind of constructs.use strict; use warnings; open my $A, '>', 'out.txt'; print $A -1 == 0 ? "A\n" : "B\n";
BTW, since the ternary operator makes your example even more confusing (I find its priority obvious but non intuitive, which means I get it right but need to think about it), it can be reduced to: print $A +1;
Edit: reduced even further from $A +1 +2 to $A +1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: map sentence with subtraction interpreted as with negative number
by rsFalse (Chaplain) on Dec 01, 2015 at 14:30 UTC | |
by Anonymous Monk on Dec 01, 2015 at 15:08 UTC |