Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to do something like this
my $foo = 192; my @things = &{$some_other_object->my_method()};
Problem is how do I pass $foo to my_method

Replies are listed 'Best First'.
Re: Passing args to a code ref?
by Zaxo (Archbishop) on Sep 13, 2005 at 05:06 UTC
    my $foo = 192; my @things = sub {$some_other_object->my_method(@_)}->($foo);

    You're flirting with a closure on $some_other_object: why not just call directly?

    my @things = $some_other_object->my_method($foo);

    After Compline,
    Zaxo

      my @things = $some_other_object->my_method()->($foo);