diff --git a/Finance/Quote/Morningstarde.pm b/Finance/Quote/Morningstarde.pm index e62cb98..15fa12c 100644 --- a/Finance/Quote/Morningstarde.pm +++ b/Finance/Quote/Morningstarde.pm @@ -84,17 +84,26 @@ sub morningstarde $info{$stock,'name'} = $namestr; }; - my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[3]'); - if (defined($pricestr)) { - my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g); - if (@splitvals) { - $info{$stock,'currency'} = $splitvals[0]; - my $converted_price = $splitvals[1]; - $converted_price =~ s/\.//g; - $converted_price =~ s/,/./g; - $info{$stock,'nav'} = $converted_price; - } - }; + my $row = 2; + while (!defined($info{$stock,'currency'}) && $row <=10) { + my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[' . $row . ']/td[3]'); + if (defined($pricestr)) { + my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g); + if (@splitvals) { + $info{$stock,'currency'} = $splitvals[0]; + my $converted_price = $splitvals[1]; + $converted_price =~ s/\.//g; + $converted_price =~ s/,/./g; + $info{$stock,'nav'} = $converted_price; + } + + # if it does not look like a currency, try next row + if ($info{$stock,'currency'} !~ /\w{2,3}/) { + undef $info{$stock,'currency'}; + } + $row++; + }; + } my $datestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[1]//span'); if (defined($datestr)) {