Hello again,
The folling code takes some data from the Australian Stock Exchage
website. The problem I am having is that I need to be able to access
the hash of the hash outside of the foreach statement. So in other
words I would like to be able to access areas within the hash
%stock_hash any where in my script. I take it I need Perl to store the
hash $stock_hash into memory and remember it. Am I on the right track
here?
At the moment the hash %stock_hash will print exactly what I want within
the foreach statement.
Kind Regards,
Dan
foreach $stock (@stocks) {
my $html_string =
get("http://www.asx.com.au/asx/markets/PriceResults.jsp?method=get&templ
ate=F1001&ASXCodes=$stock");
$te = new HTML::TableExtract( headers => [qw(Code Last \$)] );
$te->parse($html_string);
# Examine all matching tables
foreach $ts ($te->table_states) {
# print "Table (", join(',', $ts->coords), "):\n";
foreach $row ($ts->rows) {
join (',', @$row);
@downloaded_stocks = @$row;
}
%stock_hash = (
$downloaded_stocks[0] => {
"Trading Price" => "\$$downloaded_stocks[1]",
"Price Change" => "\$$downloaded_stocks[2]",
},
);
for $code ( sort keys %stock_hash ) {
print "$code: ";
for $details ( sort keys %{ $stock_hash{$code} } ) {
print "$details=$stock_hash{$code}{$details} ";
}
print "\n";
}
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>