print one xml output from multiple perl scripts that prints different xml outputs

dandan556

New Member
I have asked this question before but did not get the satisfied answer as i did not include the proper example to look at.I have multiple scripts that uses xsl to print xml output from those scripts. i want to write a one master script that calls those scripts and combine the out and print one output. could someone please help me with this?\[code\]#Example Script 1use strict;use warnings;use Data::Dumper;use XML::Simple;use Getopt::Long;my $output = '';my $debug = 0;my $path;GetOptions('path=s' => \$path,'output=s' => \$output, 'debug=i' => \$d+ebug);if($output eq ''){ die ("parameter --output=s is missing");} open my $xmloutput, ">", $outputFile or die "can not open $outputFile +"; print $xmloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-s+tylesheet type=\"text/xsl\" href=http://stackoverflow.com/"book.xsl\"?>\n<Books>\n";my $parser = new XML::Simple;my $data = http://stackoverflow.com/questions/11104389/$parser->XMLin("$path");print $xmloutput " <bookDetails> \n";print $xmloutput " <bookName>$data</bookName> \n";print $xmloutput " </bookDetails> \n";print $xmloutput " </Books> \n";close $xmloutput;\[/code\]EXAMPLE 2\[code\]EXAMPLE 2use strict;use warnings;use Data::Dumper;use XML::Simple;use Getopt::Long;my $output = '';my $debug = 0;my $path;GetOptions('path=s' => \$path,'output=s' => \$output, 'debug=i' => \$d+ebug);if($output eq ''){ die ("parameter --output=s is missing");} open my $xmloutput, ">", $outputFile or die "can not open $outputFile +"; print $xmloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-s+tylesheet type=\"text/xsl\" href=http://stackoverflow.com/"Piano.xsl\"?>\n<Piano>\n";my $parser = new XML::Simple;my $data = http://stackoverflow.com/questions/11104389/$parser->XMLin("$path");print $xmloutput " <PianoDetails> \n";print $xmloutput " <PianoName>$data</PianoName> \n";print $xmloutput " </PianoDetails> \n";print $xmloutput " </Piano> \n";close $xmloutput;\[/code\]THIS IS WHAT I AM TRYING.\[code\] my $output = ''; my $example1 = `perl script1.pl --path=c:/cygwin/home/username/directory --debug=1`; my $example2 = `perl script2.pl --path=c:/cygwin/home/username/directory --debug=1`; open my $finaloutput, ">" $output or die "cant open the file"; print $finaloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/xsl\" href=http://stackoverflow.com/"final.xsl\"?>\n<OutputDestination>\n"; my @attachscript = ($example1, $example2); for my $attached (@attachscript) { print $finaloutput "<outputgoes_here_from_script> $attached </outputgoes_here_from_script> } PRINT $finaloutput "</OutputDestination>" close $finaloutput;\[/code\]Is there any better way of doing this ?
 
Back
Top