我已经写了一个多脚本,它以xml的形式返回输出。我有xsl文件,它将从xml为每个脚本打印出一张漂亮的表格。但是我需要编写一个脚本,在其中我调用所有这些多个脚本并创建一个输出。如何从一个perl脚本调用多个perl脚本并生成输出?
可以这样做吗?如果有的话,请给我一个例子,说明如何做到这一点。
#Example Script 1
use 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=\"book.xsl\"?>\n<Books>\n";
my $parser = new XML::Simple;
my $data = $parser->XMLin("$path");
print $xmloutput " <bookDetails> \n";
print $xmloutput " <bookName>$data</bookName> \n";
print $xmloutput " </bookDetails> \n";
print $xmloutput " </Books> \n";
close $xmloutput;
实施例2
EXAMPLE 2
use 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=\"Piano.xsl\"?>\n<Piano>\n";
my $parser = new XML::Simple;
my $data = $parser->XMLin("$path");
print $xmloutput " <PianoDetails> \n";
print $xmloutput " <PianoName>$data</PianoName> \n";
print $xmloutput " </PianoDetails> \n";
print $xmloutput " </Piano> \n";
close $xmloutput;
你好Raina77ow,我提供了2个例子。因为我在这两个脚本中都使用getopt,所以我不确定如何在主脚本中调用这两个脚本并打印出结果。你能给我更多的细节吗?谢谢 – Maxyie