http://qs321.pair.com?node_id=989565


in reply to Re: If statement not working
in thread If statement not working

Use of "elsif" or hash tables don't seem to go to the point.

Actually either of those approaches does solve the problem, which is (if I'm understanding the OP correctly) that:

The OP thinks that the 'else' clause will be executed if NONE of the 'if' statements match, whereas actually the 'else' clause will be executed whenever the FINAL 'if' statement fails to match.

i.e. OP's intention was

if () {} elsif () {} elsif () {} else {}
but OP has got the syntax wrong and actually coded
if (a) {}; if (b) {}; if (c) {}; if (d) {} else {default()};
where even if one of a, b or c is true then default() is still executed (and overwrites the variable) so long as d is false.

IIU the OP correctly.