Nothing ever wants the value of an if statement.
A plain if? Probably not. An if/elsif/else statement though?
my @classifications = map { if ($_ > 0) { 'positive' } elsif ($_ < 0) { 'negative' } else { 'zero' } } @numbers;
Yes, you can write that using the ternary operator, but if/elsif/else can sometimes be clearer.
In reply to Re^5: printing unitialized value of the 'do BLOCK'
by tobyink
in thread printing unitialized value of the 'do BLOCK'
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |