How does the different behavior of the unless- and "if !" statement influence the range-operator in scalar context?
associativity, operator-precedence, perl
Solution
As the linked article says, it's a matter of associativity and precedence...
`print unless /^$/../^$/` is equivalent to `print if !(/^$/../^$/)`
`print if ! /^$/../^$/` is equivalent to `print if (!/^$/)../^$/`
Note that the first negates the range expression, while the second negates the range's beginning condition, but not the range itself.
Problem
On http://novosial.org/perl/one-liner/ I found the following two one-liners. The outputs are different because the `unless` statement is different from `if !` ( due to the associativity and precedence rules ). ``` cat file: foo bar ``` ``` perl -ne 'print unless /^$/../^$/' file foo bar ``` ``` perl -ne 'print if ! /^$/../^$/' file foo bar ``` How does the different behavior of the `if !`-statement make the second one-liner output one blank line?