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?