3

xdp ファイルの最後にタイムスタンプを追加しようとしています。XML::Twigを使用しています。スクリプトを実行すると、timestamp( <testing>4619314911532861</testing>) が最後に追加されますが、出力は ではなく STDOUT に出力されますtestdata.xdp。私は何が欠けていますか?

コード:

#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;

my $twig=XML::Twig->new(pretty_print => 'indented');
my $file = 'testdata.xdp';
$twig->parsefile_inplace($file, '.bak');
my $root= $twig->root;
my @children= $root->children;

foreach my $child (@children){
    my $eblg= new XML::Twig::Elt( 'testing', localtime);
    $eblg->paste( 'last_child', $child);
}

$twig->flush; 
4

1 に答える 1