B
Bruno Boettcher
Hello,
i have a configuration file where i am slowly migrating to XML like
notation (tryed XML:arser, but that one doesn't suit well into the
rest of my program which uses OO design...). So since the stuff is
stills simple, i throught i catch it with a normal regular
expression... but as it seems i dont get something...
the lines it has to catch are all XMl like, means
<someenv arg1="toto" arg2="titi"/> there should allways be arguments.
setup the following:
if(open(STATFILE,"$ENV{HOME}/.config"))·
{
while(my $line = <STATFILE>)
{
chomp;
if(index($line,'#') >=0 )
{
$line = substr($line,0,index($line,'#'));
}# if(index($line,'#') >=0 )
if($line && $line =~ /=/)
{
»·······#clean up to have a consistent state
»·······$line =~ s/\s+=/=/g;
»·······$line =~ s/=\s+/=/g;
»·······my @matches = ($line =~ /(\S+=".*?")*/);
»·······print("dumping args:".Dumper(\@matches));
}# if($line && $line =~ /=/)
}#while(<STATFILE>)
close(STATFILE);
}# if open STATFILE
now this thing gives me back only the first match (the first argument),
and i am wondering where the others went???
any hint welcome
i have a configuration file where i am slowly migrating to XML like
notation (tryed XML:arser, but that one doesn't suit well into the
rest of my program which uses OO design...). So since the stuff is
stills simple, i throught i catch it with a normal regular
expression... but as it seems i dont get something...
the lines it has to catch are all XMl like, means
<someenv arg1="toto" arg2="titi"/> there should allways be arguments.
setup the following:
if(open(STATFILE,"$ENV{HOME}/.config"))·
{
while(my $line = <STATFILE>)
{
chomp;
if(index($line,'#') >=0 )
{
$line = substr($line,0,index($line,'#'));
}# if(index($line,'#') >=0 )
if($line && $line =~ /=/)
{
»·······#clean up to have a consistent state
»·······$line =~ s/\s+=/=/g;
»·······$line =~ s/=\s+/=/g;
»·······my @matches = ($line =~ /(\S+=".*?")*/);
»·······print("dumping args:".Dumper(\@matches));
}# if($line && $line =~ /=/)
}#while(<STATFILE>)
close(STATFILE);
}# if open STATFILE
now this thing gives me back only the first match (the first argument),
and i am wondering where the others went???
any hint welcome