use XML::Twig; my $twig= XML::Twig->new( pretty_print => 'indented', twig_handlers => { jdk => sub{ $_->set_text( 'JDK 1.8.0_40' ) }, }, ); $twig->parsefile_inplace( 'nightly.xml', 'bak.*' ); $twig->flush; #### JDK 1.7.0_40