Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Passing subroutine as argument between packages

by Mateusz (Initiate)
on Nov 30, 2011 at 18:13 UTC ( #940914=note: print w/replies, xml ) Need Help??


in reply to Re: Passing subroutine as argument between packages
in thread Passing subroutine as argument between packages

Thank you for you answer,

I want ask you about one more thing: in this method, how pass eventually arguments for subroutine $FooConfig->important_func?

I checked $ref()->('a' ), $ref()('a'), $ref->( 'a' ), $ref->()('a'), $ref->()->('a') or like this, and didn't work.

Replies are listed 'Best First'.
Re^3: Passing subroutine as argument between packages
by chromatic (Archbishop) on Nov 30, 2011 at 18:25 UTC

    Given:

    my $ref = sub { $FooConfig->important_func( '1', @_ ) };

    ... then you can write:

    $ref->( 'more', $args, %here );

    ... though be cautious and understand how the function reference passes its arguments to the inner function.


    Improve your skills with Modern Perl: the free book.

      Simple @_ is solution - now works fine!

      Thanks for very helpfull hints.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940914]
help
Chatterbox?
[talexb]: Great quote from Re: (OT) Motivating the Unmotivated Programmer: "As Weinberg suggests, when a programmer becomes irreplaceable, it's time to replace him."
[jedikaiti]: SuicideJunkie++ #Apgrade is the highest point it will reach. They're informing you that it will all be downhill from here until the software hits a PEgrade, or impacts the terrain depending on the details of the orbit.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-07-25 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (377 votes). Check out past polls.