文件depend.ini:
UILib8.2=x
aaa=x
kkk=1.0.2
[aaa]
bbb=1.0.2
ttt=1.0.2
fff=2.6.9
[kkk]
bbb=1.0.2
ccc=1.0.2
返回结果:
apck = $VAR1 = {
'aaa' => {
'bbb' => '1.0.2',
'version' => 'x',
'fff' => '2.6.9',
'ttt' => '1.0.2'
},
'UILib8.2' => {
'version' => 'x'
},
'kkk' => {
'bbb' => '1.0.2',
'version' => '1.0.2',
'ccc' => '1.0.2'
}
};
***************************************************
readDependInfo();
sub readDependInfo
{
my $hFile;
my $line = "";
my $key = "";
my $aPack={};
my $tPack={};
my $fileName = "depend.ini";
if ( !-e $fileName){
return;
}
#print getcwd()." fileName = $fileName\n";
if (open(hFile, $fileName)) {
while ($line = ) {
$line =~ s/[\s\n]+//g;
#print $line."\n";
if ($line =~ /(.*)=(.*)/){
if ($key ne "" ){
#print "line2 = $line 1=>$1 2=>$2\n";
$tPack = $aPack->{$key};
$aPack->{$key} = $tPack;
$tPack->{$1} = $2;
}else{
print "line1 = $line 1=>$1 2=>$2\n";
$tPack = {};
$aPack->{$1} = $tPack;
$tPack->{'version'} = $2;
#print Dumper(@sPack);
}
}elsif ($line =~ /^\[(.*)\]/) {
#print "line2 = $line\n";
$key = $1;
print "line3 = $key \n";
$tPack = {};
}
}
close(hFile);
}
print "apck = ". Dumper($aPack)."\n";
return $aPack;
}
阅读(2060) | 评论(0) | 转发(0) |