When you use "==", both the left and right sides are evaluated in numeric context. Since, in numeric context, " " and 0 are equivalent (and are also numerically equivalent to both undef and "" btw), your 'if' and 'elsif' conditions are effectively identical.
That is, if $val == " " is true, then so is $val == 0, and vice-versa