sathish is a good bou
</subchap1> </chapter> </xml> 2.<xml> <chapter>head <subchap1>bodypara
</subchap1> </chapter> </xml> this two xml files are my inputs i want the output as <xml> <head>sathish <body>sathish is good boy or not <para>sathish is a good bou</para> <//body> </head> </xml> i mean the second xml file contents are replaced to the first xml file tags please help any one how can i do this i use the code as #!/usr/bin/perl -w use warnings; use strict; use XML::Simple; use Data::Dumper; my %hash; my %hash1; my $file= $ARGV[0]; my $simple = XML::Simple->new(); my $hash = $simple->XMLin($file); my $file1= $ARGV1; my $hash1 = $simple->XMLin($file1); print Dumper ($hash); print Dumper ($hash1); my $areEqual=1; if(keys %hash == keys %hash1) { foreach my $key(keys %hash) { if(!exists $hash1{$key}) { $areEqual=0; last; } } } if($areEqual) { print "ARE "; } else { print "ARE NOT "; } for (keys %hash) { $hash{$_} = $hash1{$_} if exists $hash1{$_}; } print Dumper ($hash); print Dumper($hash1); $simple->XMLout($hash, KeepRoot => 1, OutputFile => 'pets.xml', XMLDecl => "<?xml version='1.0'?>", ); $simple->XMLout($hash1, KeepRoot => 1, OutputFile => 'pets1.xml', XMLDecl => "<?xml version='1.0'?>", ); this code converts the two xml files to hash value and compare the two hash keys are same if there are same keys replace the first hash keys with second hash values what is the error and please suggest me how can i do thisIn reply to Re^2: how can i replace a hash key with other hash value?
by satzbu
in thread how can i replace a hash key with other hash value?
by satzbu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |