BOBJaneBOBJaneBOBJaneBOBJaneBOBJaneBOBJaneBOBJaneBOBJane #### #!/usr/bin/perl use strict; use warnings; use File::Find; use XML::Twig; @ARGV = ('.') unless @ARGV; my $dir = shift @ARGV; find(\&edits, $dir); sub edits() { my $seen = 0; my $file = $_; if ($file eq 'data.xml') { my $orig = 'data.xml'; use autodie 1.999; use POSIX 'strftime'; my $back = $orig . strftime( '-%Y-%m-%d', localtime ); rename $orig, $back; open my $newfh, '>', $orig; my $t = XML::Twig->new( twig_roots => { 'merchant' => sub { my ( $t, $value ) = @_; { my $ra = $value->text; $ra =~ s/_/ /g; $value->set_text($ra); } $value->print($newfh); }, }, twig_print_outside_roots => $newfh, ); $t->parsefile($back); $t->flush; #don't forget undef $t; # close $newfh; } }