use warnings; use strict; use XML::Twig; my $xmlstr = ' Hello '; my $twig = XML::Twig->new(twig_handlers => {'XML/TestElement' => sub {$_->set_text('Bye')} }); $twig->parse($xmlstr); $twig->print(); __END__ Bye