No. But then I wouldn't code unless( not $var ){ in the first place, and I wouldn't transform a legitimate use of unless into if( not ... ).
But I would happily code unless( $var ) { in preference to if( not $var ){.
And if the logic of my code dictates that using a guard statement to quit early is preferable to an extended if statement, then I prefer the OP's:
unless( -d or $_ eq '.' or $_ eq '.. ) { die ... }; which I read as
Unless it's a directory and it's neither '.' nor '..' get the hell outta here.
which I think reads easily, and far better than either
if( not( -d or $_ eq '.' or $_ eq '.. ) ) { die ... }; which I'd have to read as
If( not( it's a directory and it's neither '.' nor '..' ) ) get the hell outer here.
or
if( !-d or ( -d and ( $_ ne '.' or $_ ne '..' ) ) ) { die ... }; and read as
If( it's not a directory or ( it is a directory but it's either '.' or '..' ) ) get the hell outta here.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.