Gossamer Forum
Home : General : Perl Programming :

How I can get more same $var from one field in db and loop it?

Quote Reply
How I can get more same $var from one field in db and loop it?
Hi all!

I have in db in field1=

<OPTION>05092005"> - 2053 &euro;</OPTION>

<OPTION>06092005"> - 1053 &euro;</OPTION>

<OPTION>07092005"> - 3020 &euro;</OPTION>

and I want to get euro value so 2053, 1053 and 3020

Whan I put

$var = $row[0];
$var =~ /-\s*(.*)\s*&euro;/g;
$var=$1;
print "Prix::".$var."\n";

I get only first value (2053)

So my question is how to get all other information
$var=2053, $var=1053 and $var=3020??????????????
Quote Reply
Re: [PerlElvir] How I can get more same $var from one field in db and loop it? In reply to
Untested, but should work :)

Code:
my $var = $row[0];
while ($var =~ m|\Q<OPTION>\E([\d+]?)\Q"> - \E([\d+]?)\Q &euro;</OPTION>\E|i) {
print "Got: $1, and $2 \n";
}

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates