if Flow control command |
Usage |
if (<condition>) <command1> [else <command2>] |
Description |
Executes <command1> if the <condition> evaluates to true (non zero result). If the else part is given, <command2> is executed. If the <condition> evaluates to false (result == '0'). the <condition> is an expression evaluated in the same way as $(*) with the following extensions: If the <condition> is a string, its length is evaluated - in this way a non-empty string causes the <condition> to be true, and an empty string causes it to be false. If the <condition> is an array, its size is evaluated - a non-empty array is true, an empty array is false. If the <condition> is a hash, the number of its entries is evaluated - a non-empty hash is true, an empty hash is false. |
Examples |
if(%a != 10) echo \%a was != 10 else echo \%a was 10! |
See also |
Expression evaluation identifier |