use strict; use warnings; use XML::Twig; my $fileName = 'Conf.xml' my $twig = XML::Twig->new( twig_roots => { StartPoint => \&ReplaceAtriValue }, twig_print_outside_roots => 1, ); sub ReplaceAtriValue { my ($twig, $startPoint) = @_; if ( '09' eq $startPoint->att('Hours') ) { $startPoint->set_att( Hours => '12'); } $startPoint->print(); } $twig->parsefile($fileName);