in reply to XML::twig using a hash in twig_roots

I don't have much time to answer, but it seems to me that the values of the hash you are passing as argument to twig_roots are just strings, strings that contain sub { upd_param(@_, 7) }, but strings nevertheless. You need the value to be a real function: (untested): $PARAMS{$key}= sub { upd_param(@_, $val) };