Hi,
Below is the script I have written to change the value of one of the parameter in an XML file situated at a different location:
#!/usr/bin/perl -w
use Cwd;
use XML::Simple;
use Data::Dumper;
no warnings;
my $before_upgrade_value = &pre_upgrade_value;
print "Value before upgrade:: $before_upgrade_value \n";
&change_value ($before_upgrade_value);
&change_value ("America");
my $after_upgrade_value = &pre_upgrade_value;
print "Value after upgrade:: $after_upgrade_value \n";
print "Done \n";
sub pre_upgrade_value {
my $xml = new XML::Simple;
# read XML file
my $input_xml = "/usr/tmp/country/CountryConfig.xml";
my $data = $xml->XMLin($input_xml);
my $arg0 = $data->{COMMON}->{COUNTRY_LIST}->{Value};
print "Arg0 is $arg0 \n";
return $arg0;
}
sub change_value {
my $arg0 = shift;
my $arg1 = "ENGLAND";
my $arg2 = "/usr/tmp/country/CountryConfig.xml";
system("perl -pi -e 's/$arg0/$arg1/' $arg2");
}
But I am getting the following error:
Unable to recognise encoding of this document at /usr/local/lib/perl5/site_perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 100. Document requires an element [Ln: 1, Col: 0]
Can you tell me the reason as I am not calling EncodingDetect.pm in my code?