http://qs321.pair.com?node_id=1232052


in reply to Re: Function name in a variable, can't recall the concept
in thread Function name in a variable, can't recall the concept

That's OK, from examples above:

use strict; use warnings; package Object; sub new { return bless \{} } sub foo { printf "hello foo = %s\n", ( caller(0) )[3]; } sub bar { printf "hello bar = %s\n", ( caller(0) )[3]; } package main; my $someObject = Object->new(); my $someCondition = 0; my $funcname = ( $someCondition ? 'foo' : 'bar' ); $someObject->$funcname($funcname); $someCondition = 1; $funcname = ( $someCondition ? 'foo' : 'bar' ); $someObject->$funcname($funcname);