in reply to Re^5: Is this the most elegant way to code directory lookup?
in thread Is this the most elegant way to code directory lookup?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Is this the most elegant way to code directory lookup?
by ikegami (Patriarch) on Sep 29, 2006 at 19:59 UTC | |
by BrowserUk (Patriarch) on Sep 29, 2006 at 21:12 UTC |