GrandFather has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to inplace edit using XML::Twig, or have I got to go through the pain of creating a temporary file and replacing the original? Is there a better way to do that than the following?
# Edit the manifest my $saveStdOut = select; my $manifestOut; open $manifestOut, '>', "$manifestPath.new"; select $manifestOut; $sub = bindArgs (\&insertFiles, $absDir, \@fileList); my $twig = XML::Twig->new ( discard_spaces => 1, pretty_print => 'indented', twig_roots => {'sourceFiles' => $sub,}, # Insert file list twig_print_outside_roots => 1, # Print the rest ); $twig->parsefile ($manifestPath); select $saveStdOut; close $manifestOut; unlink $manifestPath; rename $manifestPath . '.new', $manifestPath;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inplace edit using XML::Twig
by mirod (Canon) on May 22, 2006 at 10:02 UTC | |
by aufflick (Deacon) on May 23, 2006 at 08:05 UTC | |
|
Re: Inplace edit using XML::Twig
by kvale (Monsignor) on May 22, 2006 at 03:40 UTC | |
by gellyfish (Monsignor) on May 22, 2006 at 08:34 UTC | |
by greenFox (Vicar) on May 22, 2006 at 08:07 UTC |