Many thanks to all and in particular to Mac_Gyver who hit it right on. I change my == to === and everything works fine.
But I must say it is very peculiar because all of my if's wit == were working fine except this particular one and I'm pretty sure I had similar situations.
For the one giving trouble, I had set the $sw='' (which I thought was a blank or nothing) but when I printed it, it was a numeric 0 (which obviously gave me the trouble when I was checking for a 'B"). However, I had at least one other situation where I set $WL='' and when testing for a W, if($WL=='W') ,I was getting correct results (or so it seems - maybe the results were incorrect and I didn't notice it - that's the only explanation I have.)
Again, many thanks.