请看一下以下代码的问题,小弟初学perl,请多指教
ini的配置文件如下:
[codestring]
home=D:\Develop\ECIF创新内部研发项目\产品
error=非法输入请重新输入
[codestring::part1]
help=生成codestring数据\n Usage:model.pl 1 [output]\n output 输出文件
xml=$home . "template\\model\\codestring.xml";
xsl=$home . "template\\model\\codestring_data.xsl";
p3=author
p4=version
cmd=xalan -p date '" . $date ."' " . $xml . " ". $xsl
[codestring::part2]
help=生成codestring转换程序\n Usage:model.pl 2 [output]\n output 输出文件
xml=$home .template\\model\\codestring.xml
xsl=$home. template\\model\\codestring_explain2c.xsl
p3=author
p4=version
cmd=xalan -p date '" . $date ."' " . $xml . " ". $xsl
;end of ini
perl解析ini文件的脚本如下:
use Config::Abstract::Ini;
my $ini_path="c:\\";
my $settingsfile = $ini_path."codestring.ini";
my $ini = new Config::Abstract::Ini($Settingsfile);
my %settings = $ini->get_entry('codesting');
my $home = $settings->get_entry_setting('codestring','home');
($val,$p3,$p4)=@ARGV;
my $count=3;
if (@ARGV!=$count)
{my $error = $settings->get_entry_setting('codestring','error');
print $error;}
my $date = getTime();
if(defined($p3)&&defined($p4))
{my %part1 = $ini->get_entry_setting('codestring','$val');
my $help = $($val){'help'};
my $xml = $($val)('xml');
my $xsl = $($val)('xsl');
my $p3 = $($val)('p3');
my $p4 = $($val)('p4');
my $cmd = $($val)('cmd');
print `$cmd`;}
else
{print $help;}
sub getTime #日期函数
{
my $time = shift || time();
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time);
$year += 1900;
$mon ++;
$min = '0'.$min if length($min) < 2;
$sec = '0'.$sec if length($sec) < 2;
$mon = '0'.$mon if length($mon) < 2;
$mday = '0'.$mday if length($mday) < 2;
$hour = '0'.$hour if length($hour) < 2;
my $weekday = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')[$wday];
return { 'second' => $sec,
'minute' => $min,
'hour' => $hour,
'day' => $mday,
'month' => $mon,
'year' => $year,
'weekNo' => $wday,
'wday' => $weekday,
'yday' => $yday,
'date' => "$year-$mon-$mday"
};
}
请问各位大虾,以上的perl解析ini文件,能符合要求么,
要求是能拼出xalan命令来,并用反引号执行这个cmd命令,各位大虾给分析一下,小弟在这里多谢多谢了。