in reply to Calling subroutines based on variable names...
Use a dispatch table:
my @the_args = 0..5; my %functions = ( a => { x => \&sub_a_text_x, y => \&sub_a_text_y, }, b => { x => \&sub_b_text_x, y => \&sub_b_text_y, }, ); if( exists $functions{$var1} && exists $functions{$var1}{$var2} ) { $functions{$var1}{$var2}->(@the_args); } else { die "A horrible death"; }
TGI says moo
|
|---|