As a Perl fossil I recognise this syntax as equivalent to if(not @myarray) which does the same thing. And here I was thinking Guido had deliberately aimed to avoid Perlisms in Python.
That said, the Perlism in question is the right* way to do it in Perl. The length operator does not do the expected thing on an array variable. (You get the length of the stringified length of the array. And a warning if those are enabled.)
* You can start a fight with modern Perl hackers with whether unless(@myarray) is better or just plain wrong, even if it works and is equivalent.
Empty sequences being false goes back a lot further than perl, it was already a thing in the first lisp (in fact the empty list was the cannonical false).
As a Perl fossil I recognise this syntax as equivalent to
if(not @myarray)
which does the same thing. And here I was thinking Guido had deliberately aimed to avoid Perlisms in Python.That said, the Perlism in question is the right* way to do it in Perl. The
length
operator does not do the expected thing on an array variable. (You get the length of the stringified length of the array. And a warning if those are enabled.)* You can start a fight with modern Perl hackers with whether
unless(@myarray)
is better or just plain wrong, even if it works and is equivalent.Empty sequences being false goes back a lot further than perl, it was already a thing in the first lisp (in fact the empty list was the cannonical false).