View Single Post
  #3   (View Single Post)  
Old 6th February 2014
thirdm thirdm is offline
Spam Deminer
Join Date: May 2009
Posts: 234

The part that nagged me wasn't that there was an elsif, it was that it said...

if (defined(A) && A) ...

instead of just

if (A)

I think, for a check like this in boolean context, if it is the case that $ENV{SHELLVAR} is not in the hash or in the hash with an undefined value or in the hash with a blank or zero value, it's all the same as far as the condition and "if ($ENV{SHELLVAR})" covers it. My experiments seem to confirm this, but I could be missing something. Perl is pretty complicated when you try to analyze the dwim stuff.

It seems to have been this way since the first version by Chris Kuethe. Good of you to look to the history. I should have done that.

I'm a little wary sending this to misc. I've got this intuition this might be something that's really annoying for me to point out (though apparently not so annoying not to bother you guys with it ... sorry). The last person I want to annoy with novice Perl questions is Marc Espie. Pretty sure there's no practical harm or performance problem to the double check, it just bugs me reading it.

Maybe I could try the local Perl mongers see if they know why someone would write it this way.

Last edited by thirdm; 6th February 2014 at 07:18 PM. Reason: clarification
Reply With Quote