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
    "...why not something like..."

    Yes sure. I tried i already. Because of...

    karls-mac-mini:MyMoo karl$ ./run.pl Prototype mismatch: sub Utils::uniq (@) vs none at Utils.pm line 20. Compilation failed in require at /Users/karl/perl5/perlbrew/perls/perl +-5.20.0threads/lib/site_perl/5.20.0/Module/Runtime.pm line 317. Compilation failed in require at ./run.pl line 7. BEGIN failed--compilation aborted at ./run.pl line 7.

    ...what i don't understand (for the moment). OK, I should have mentioned it...sorry.

    Best regards and thanks for advice, Karl

    «The Crux of the Biscuit is the Apostrophe»

        This works!

        Some might say that this issue was obvious ;-)

        Thanks for advice BrowserUK and best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

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
    "...Does Moo interfere with the propagation of context in some way..."

    I guess it doesn't. Same behavior without wantarray.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»