I admit, I made a boo boo on c&ping my third attempt--and that's the point. I would not make that mistake in my code, because I wouldn't be trying to avoid the obvious solution--unless as used by the OP.
I started to respond when you only had two "easiest to understands". The addition of the last one rendered that arguement moot because you are now offering the OPs version--which is (IMO) the simplest and best.
Your first option is bad because it tests all three sub-conditions every time, whereas the original short circuits.
Your second best is the worst.
I have no idea what none is or where it comes from, but I assume you are having to:
- Load a module.
- Invoke a function -- with callback.
- And still you are testing all sub-conditions instead of short circuiting.
And all of that to avoid using a perfect serviceable built in keyword.
... unless it's a directory, '.', or '..'
... unless ( -d || $_ eq '.' || $_ eq '..');
(Because of the resemblance to English and French.)
This is perfect because it exactly reflects the thought process that lies behind the code.
"Unless they give me something that is a directory, or if they give me '.' or '..'; die."
And that's the point I've been trying to make. Sometimes the emphasis is on the negative and unless exactly lends itself to this.
This is why a mother will often choose to say:
Stay here unless I call you.
In preference to
Come to me when I call you.
Because she wishes to emphasis "Stay here...", not "come when I call". And so it is in programming. There are occasions when the logic requires a particular emphasis, and whilst DeMorgan may allow you to invert the logic of the condition successfully--if applied correctly--it will leave you with a statement with the wrong emphasis.
And this is where all the arguements for avoiding unless fall down. They continually say that DeMorgan is hard (it is); and so you are likely to make mistakes when converting a if into an unless--but they seem to miss that they same is true going the other way. Converting something that is a natural unless to an if in order to avoid using unless is stupid because it is subject to the exact same set of potential errors and mistakes as going the other way.
My position is that you use if, when it reflects the natural thought process, or the structural requirements of the code. And you use unless when that reflects the natural thought process or the structural needs of the code.
Ie. Don't use one, when the other is better.
And dogmatic "thou shalt nots" do everyone a disservice because they force the use of DeMorgan and all the mistakes that come with it in one set of the two.
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.