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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!