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: <%-(-(-(-<
In reply to Re: Moo From Hell #1: How to proxy a sub from a non OO module
by AnomalousMonk
in thread Moo From Hell #1: How to proxy a sub from a non OO module [SOLVED]
by karlgoethebier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |