1 while s/<([^<]+?)>([^<]*?)<\/>/ $_{$1}->{$2} ||= do { #TODO: Make sure $1 doesn't contains "::". my $func = $pkg . "::" . $1; #TODO: Make sure $func exists. no strict 'refs'; $func->($2) } /e; #### my %cb = ( use => \&use, dbl => \&dbl, ); 1 while s/<([^<]+?)>([^<]*?)<\/>/ #TODO: Make sure $cb->{$1} exists. $_{$1}->{$2} ||= $cb->{$1}->($2) /e;