Your last expression is not equivalent to the others.
if( !-d or ( -d and ( $_ ne '.' or $_ ne '..' ) ) )
means
unless( -d and $_ eq '.' and $_ eq '..' )
It should have been
if ( !-d and $_ ne '.' and $_ ne '..' ) { ... }
"If it's not a directory, not '.' and not '..', then ..."
I can't understand
"Unless it's a directory and it's neither '.' nor '..' get the hell outta here."
I don't even know what it would be if it were grammatically correct English. Would it be
"Unless it's a directory, and unless it's neither '.' nor '..', get the hell outta here."
or
"Unless it's a directory, and if it's neither '.' nor '..', get the hell outta here."?
The answer is kinda moot since I don't understand either version.
By far, the three easiest for me to understand are:
"If it's not a directory, not '.' and not '..', then ..."
if ( !-d && $_ ne '.' && $_ ne '..' ) { ... }
(Because the tight binding makes it easier to process mentally.)
"If it's neither a directory, '.', nor '..', then ..."
if ( none -d, $_ eq '.', $_ eq '..' ) { ... }
(Because of the resemblance to English and French.)
... unless it's a directory, '.', or '..'
... unless ( -d || $_ eq '.' || $_ eq '..');
(Because of the resemblance to English and French.)
In reply to Re^7: Is this the most elegant way to code directory lookup?
by ikegami
in thread Is this the most elegant way to code directory lookup?
by texasperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |