in reply to creating operands
No. That was actually one of the issues that perl 6 is supposed to address: the ability to add new operators. All we have today are existing operators and functions.
I think that's as good as you're going to be able to do before perl 5.9.2.sub definedor { defined $_[0] ? $_[0] : $_[1] }
Of course, if you want a more generic one that can take multiple inputs, sort of emulating $a // $b // $c // ..., you could do:
and use it as definedor($a, $b, $c, ...) Of course, at this point, you almost may as well use the first function directly ;-)sub definedor { use List::Util qw(first); first { defined } @_ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: creating operands
by ikegami (Patriarch) on Jul 13, 2006 at 17:52 UTC |