$_->set_content( $_->text + 10); $_->print; #### #!/usr/bin/perl -w use strict; use XML::Twig; XML::Twig->new( twig_roots => { number => sub { $_->set_content( $_->text + 10) ->print; } }, twig_print_outside_roots => 1, ) ->parse( \*DATA); __DATA__ 2 Y 1 N