in reply to wantarray alternative
#include disclaimer on why one-liners are generally undesirable.
Consider a ternary operator. Specifically:
condition ? result_if_true : result_if_false
You could then make this function:
wantarray ? first {$_} map { lc } @_ : map { lc } @_ ;
Note also - return is (almost) redundant if it's the last line of the code - by default Perl returns from a sub 'the result of the last operation'. This too though, isn't always a good thing, because readable code almost always trumps really short code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: wantarray alternative
by Your Mother (Archbishop) on Jul 10, 2013 at 18:50 UTC | |
|
Re^2: wantarray alternative
by tqisjim (Beadle) on Jul 10, 2013 at 19:04 UTC |