regexp catching variable number of name=value fields?

B

Bruno Boettcher

Hello,

i have a configuration file where i am slowly migrating to XML like
notation (tryed XML::parser, 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top