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 | |
|
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 |