in reply to nonempty false list
«if» imposes a scalar context on the condition. That means the conditional expression is incapable of returning a list. The list can't possibly be empty, not empty, true or false if it doesn't even exist.
A hash slice in scalar context returns the last element, so
is the same asif (@x{1,2})
if ($x{2})
The following operators evaluate EXPR in list context and count the number of returned values:
if (@{[ EXPR ]}) # Array if (map 1, EXPR) # map if (grep 1, EXPR) # grep if (() = EXPR) # List assignment if (count(EXPR)) # External function such as # sub count { 0+@_ }
|
|---|