你好 jonny,
sorry, der Code war so natuerlich quatsch. Nochmal in richtig:
sub get_conf {
my $file = shift;
my $conf = {};
my $sect = '';
local *DAT;
open DAT,'<',$file or do {
print STDERR "Could not open file $file: $!";
return;
};
while(my $line = <DAT>) {
if($line = /^\s*\[\s*(\w+)\s*\]) {
$sect = $1;
$conf->{$sect} = [$conf->$sect] if exists $conf->{$sect};
next;
}
if($line =~ /^\s*(\w+)=(.*)$/) {
$sect = 'global' unless $sect;
if(ref $conf->{$sect} eq 'ARRAY') {
if(exists $conf->{$sect}->[-1]->{$1}) {
$conf->{$sect}->[-1]->{$1} = [$conf->{$sect}->[-1]->{$1}];
push @{$conf->{$sect}->[-1]->{$1}},$2;
}
else {
$conf->{$sect}->[-1]->{$1} = $2;
}
}
else {
$conf->{$sect}->{$1} = $2;
}
$sect = '' if $sect eq 'global';
next;
}
$sect = '' if $line =~ m!\[/\]!;
}
close DAT;
return $conf;
}
Jetzt sollte es passen... hatte die doppelten Sachen nicht
beruecksichtigt.
再见,
CK
--
So, wie ein Teil ist, ist das Ganze.
So, wie ein Teil ist, ist das Ganze.