in reply to Moo From Hell #1: How to proxy a sub from a non OO module [SOLVED]
I can't test this ATM, it's just a guess, but why not something like:
package Utils; ...; use List::MoreUtils (); # note empty optional import list ...; ...; sub uniq { my $self = shift; # fully qualify List::MoreUtils function my @result = List::MoreUtils::uniq @{ $self->list }; wantarray ? @result : scalar @result; } ... 1; # And the script: ... use Karl; ... ... my $uniq = $nose->uniq; ...
Update: (Update: And a bit OT:) Does Moo interfere with the propagation of context in some way I'm not aware of? If not, the return statement of my_uniq() in the OPed code
wantarray ? @result : scalar @result;
would seem to return exactly what would be returned anyway in list or scalar context by just returning an array, i.e., the same as a
return @result;
statement. It makes no particular difference, but I was just curious.
Give a man a fish: <%-(-(-(-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moo From Hell #1: How to proxy a sub from a non OO module
by karlgoethebier (Abbot) on Aug 02, 2015 at 18:06 UTC | |
by BrowserUk (Patriarch) on Aug 02, 2015 at 18:19 UTC | |
by karlgoethebier (Abbot) on Aug 02, 2015 at 18:47 UTC | |
by Your Mother (Archbishop) on Aug 02, 2015 at 20:16 UTC | |
by karlgoethebier (Abbot) on Aug 02, 2015 at 20:54 UTC | |
| |
|
Re^2: Moo From Hell #1: How to proxy a sub from a non OO module
by karlgoethebier (Abbot) on Aug 02, 2015 at 18:12 UTC |