Subject: | Error when using parsefile_inplace on a system without Perl (using PDK) |
When using parsefile_inplace, I cannot "compile" my script using PDK anymore.
The parsefile_inplace() method will throw an error such as:
"perl" is not recognized as an internal or external command, operable program or batch file.
This is my sample script:
#!perl
use utf8;
use 5.016003;
use strict;
use warnings;
binmode STDOUT, ':utf8';
use XML::Twig;
# -- PerlApp explicit uses
use File::Temp; # for XML::Twig inplace methods
# -- /PerlApp explicit uses
my $source_file = 'source.xml';
my $target_file = 'target.xml';
create_source_file($source_file);
my $t = XML::Twig->new(
output_encoding => 'UTF-8',
output_filter => 'safe',
twig_roots => { 'seg' => sub{
my ($t, $seg) = @_;
$seg->set_text('blubb');
$seg->flush;
} },
twig_print_outside_roots => 1,
);
$t->parsefile_inplace($source_file, '.bak');
$t->flush;
say "> done";
exit(0);
sub create_source_file {
my $file_name = shift or die('Missing file name');
open(my $fh, '>', $file_name) or die "Could not open file: $!";
print $fh q~<root>
<seg>bla</seg>
<x>y</x>
</root>~;
close($fh);
return;
} # /create_source_file
Not sure if you can do anything about it.
But maybe it's something about the temp file handling?