in reply to wantarray alternative
Isn't first { $_ } @array the same as $array[0]? (except where $array[0] contains a "false" value.)
sub lowercase { return ( wantarray ) ? map { lc } @_ : lc $_[0]; }
Is your intended use of 'first' really just looking for elements that contain some non-false value (because that's what it does)? If so:
return ( wantarray ) ? map { lc } @_ : lc( first { $_ } @_ );
ie, no need to 'lc' the entire @_ if you are only returning one. Find the one you want, 'lc' it, and return that.
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: wantarray alternative
by tqisjim (Beadle) on Jul 10, 2013 at 19:38 UTC | |
by LanX (Saint) on Jul 10, 2013 at 19:53 UTC | |
by tqisjim (Beadle) on Jul 10, 2013 at 20:22 UTC | |
by LanX (Saint) on Jul 10, 2013 at 20:24 UTC | |
by tqisjim (Beadle) on Jul 10, 2013 at 21:04 UTC | |
| |
by davido (Cardinal) on Jul 10, 2013 at 19:59 UTC | |
by tqisjim (Beadle) on Jul 10, 2013 at 20:35 UTC |
In Section
Seekers of Perl Wisdom