Hi! found myself coding a lot of ugly statements like this:
$foo = $bar if defined $bar;This is fine unless $bar is a complex statement or a function that I don't want to call twice. Of course I could create a temporary variable which makes the code even uglier:
$tmp = bar(); $foo = $tmp if defined $tmp;What I would like is a short and simple syntax where I only have to type each part of the conditional assignment once:
$foo =ifdef $barAny ideas? The code should be short and readable. Bonus points if $foo can also be a list.
In reply to Assignment to a value only if it is defined by voj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |