hi,
I rewrote your script altogther, changing all your wrongly use printf to print and then using "my" for all your arrays, using warnings and strict. I figured your get function was from LWP::Simple module. And I got output. See below:
use strict;
use warnings;
use LWP::Simple;
sub stockquotegetter {
my @quotes;
my $html = get("http://www.iex.nl/Koersen/Aandelen.aspx")
or die "Couldn't fetch the stock quotes";
my(@url,@url1,@url2);
foreach my $aandeel (@_) {
@url = split( /Realtime koers $aandeel/, $html );
@url1 = split( /LastPrice"><span>/, $url[1] );
@url2 = split( /</, $url1[1] );
#$html =~ m{basevalues['11754LastPrice'] = ([\d,]+) ;};
#printf $_;
#printf $sales_rank
#$html =~ m{ '11754LastPrice'] = (.*?);}i; # extract destinati
+on of link
#$url = $1;
print "$aandeel $url2[0]\n";
push( @quotes, $url2[0] );
}
print @quotes;
}
print stockquotegetter(
qw(Aegon Aperam ING ASML DSM Boskalis KPN Randstad PostNL TomTom))
+;
OUTPUT
Aegon 4,08
Aperam 11,04
ING 5,65
ASML 45,91
DSM 37,85
Boskalis 26,82
KPN 6,73
Randstad 25,76
PostNL 2,90
TomTom 3,47
4,0811,045,6545,9137,8526,826,7325,762,903,471
Please, note that the reconstruction was based on several assumptions. This is not the best re-write, you could get though. There are still several things, you could optimise. Please, compare your code with mine and get the best of the two! Please, forgive my assumptions if they were wrong. I was only trying to help blindly!! :)
|