我已經寫了一個多腳本,它以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