in reply to check for existing value, else set to default
or$a = $a ? $a : "default_value";
don't work if the value of $a is something that returns false in a boolean context, like 0 or "". For now,$a ||= "default_value";
is the best way to write this, and since it's such a common idiom, Perl 6 will allow you to say$a = defined $a ? $a : "default_value";
whenever Perl6 will come out.$a //= "default_value";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
//= is coming in perl 5.10.0
by PodMaster (Abbot) on Apr 26, 2004 at 06:37 UTC |