Dave Saville said:
Came across this today
print "1 OK\n" and next unless (length $line[0]);
Never seen that construct before. Is it just some perlish shorthand
to get stuff on one line?
In this case, it's just a verbose and somewhat byzantine way to express
print("1 OK\n), next unless length($line[0]);
Generally, the so-called 'logical operators', (||, &&, //, and, or)
don't evaluate their right-hand arguments if the value of the combined
expression is already known after evaluating the left-hand
argument. This implies they can be used for flow-control in the sense
that code making up the right-hand argument will only be executed when
executeing the code of the left-hand argument wasn't sufficient to
determine the result of the expression. The line you quoted is a bad
example because the 'next' isn't really executed conditionally because
the print-statement always returns true. A better example could be
something like
$age >= 18 or die("Won't sell this to you.");