in reply to Moose: Accessing subroutines in packages used by Moose class

You can use code to write your wrappers:

require X11::GUITest; for my $imported (qw/SendKeys FindWindowLike ClickWindow SetEventSendD +elay/) { my $func = "X11::GUITest::$imported"; my $code = do { no strict 'refs'; \&{"$func"} }; my $delegate = sub { my( $self, $arg ) = @_; $code->($arg); }; # Install as mySendKeys etc: no strict 'refs'; *{"my$imported"} = $delegate; };

Replies are listed 'Best First'.
Re^2: Moose: Accessing subroutines in packages used by Moose class
by nysus (Parson) on Apr 17, 2016 at 12:43 UTC

    Awesome, thanks! Amazing how you can whip that kind of code out. It literally would have taken me a day or more to figure out how something like this could be accomplished.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Re^2: Moose: Accessing subroutines in packages used by Moose class
by nysus (Parson) on Apr 17, 2016 at 19:57 UTC

    I gave it a whirl but X11::GUITest complained with:

    Use of uninitialized value $titlerx in regexp compilation at /usr/lib/ +x86_64-linux-gnu/perl5/5.20/X11/GUITest.pm line 347. Use of uninitialized value $titlerx in regexp compilation at /usr/lib/ +x86_64-linux-gnu/perl5/5.20/X11/GUITest.pm line 347. ... Repeated many more times ... Use of uninitialized value $titlerx in regexp compilation at /usr/lib/ +x86_64-linux-gnu/perl5/5.20/X11/GUITest.pm line 347. Use of uninitialized value in subroutine entry at /usr/lib/x86_64-linu +x-gnu/perl5/5.20/X11/GUITest.pm line 545.

    Do you happen to have an inkling of what the issue might be? If not, don't worry about it, I'll just write the wrapper manually. I learned something. Maybe this technique just doesn't work on this particular module.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      Without seeing your code and without knowing about what X11::GUITest expects as the parameters, I can't tell.