in reply to Re^2: How to access an object method when method name is stored in scalar variable
in thread How to access an object method when method name is stored in scalar variable

You can always create a new scalar that holds the full method name before making the call :)

my $method = "foo"; my $full_method = "set_$method"; my $return_value = $obj->$full_method;

Or you could even do  (though that's a bit ugly):

my $ret_value = $obj->${\"set_$method"};

Replies are listed 'Best First'.
Re^4: How to access an object method when method name is stored in scalar variable
by AnomalousMonk (Archbishop) on Mar 16, 2011 at 01:02 UTC

    And this approach is fully orthogonal for passing parameters:

    >perl -wMstrict -le " { package Foo; sub new { return bless { foo => 'woo' } => shift; } sub hoo_foo { my $self = shift; print qq{hi from hoo_foo: $self->{$_[0]}}; } } ;; my $oo = Foo->new; my $poo = 'foo'; my $method = qq{hoo_$poo}; $oo->$method($poo); $oo->${ \qq{hoo_$poo} }($poo); " hi from hoo_foo: woo hi from hoo_foo: woo
Re^4: How to access an object method when method name is stored in scalar variable
by tj_thompson (Monk) on Mar 15, 2011 at 21:37 UTC
    Haha so the straightforward obvious easy way to do it huh? *sigh* I hate missing those. Thank you once again :)