When you want to group stuff by name or other non-numeric identifier use a hash. Consider:
use strict;
use warnings;
my %quotes = comgetter ('Goud', 'Koper');
for my $aandeel (keys %quotes) {
print "$aandeel: $_\n" for @{$quotes{$aandeel}};
}
sub comgetter { #platinum enzo werkt allemaal nog niet
my %quotes;
my $html = do {local $/; <DATA>};
foreach my $aandeel (@_) {
my @url = split (/title=\s*"$aandeel"/, $html);
my @url1 = split ('</td>\s*<td', $url[1]);
my @url2 = split (/>/, $url1[1]);
push @{$quotes{$aandeel}}, $url2[-1];
}
return %quotes;
}
__DATA__
<html>
<head></head>
<body>
<table class="genTable openTable quotesSideBlockTable collapsedTab
+le">
<tbody>
<tr class="LeftLiContainer Selected" pair="8830" id="sb_pair_8
+830"
chart_link="/commodities/gold-streaming-chart">
<td class="sideColumn"> </td>
<td class="left bold first"><a href="/commodities/gold" titl
+e=
"Goud">Goud</a></td>
<td class="lastNum" id="sb_last_8830">1670.75</td>
<td class="chg greenFont" id="sb_change_8830">+0.15</td>
<td class="chgPer greenFont" id="sb_changepc_8830">+0.01%</t
+d>
<td class="icon"><span class="newSiteIconsSprite redClockIco
+n" id=
"sb_clock_8830"> </span></td>
<td class="sideColumn"> </td>
</tr>
<tr class="LeftLiContainer" pair="8836" id="sb_pair_8836" char
+t_link=
"/commodities/silver-streaming-chart">
<td class="sideColumn"> </td>
<td class="left bold first"><a href="/commodities/silver" ti
+tle=
"Zilver">Zilver</a></td>
<td class="lastNum" id="sb_last_8836">30.735</td>
<td class="chg greenFont" id="sb_change_8836">+0.279</td>
<td class="chgPer greenFont" id="sb_changepc_8836">+0.92%</t
+d>
<td class="icon"><span class="newSiteIconsSprite redClockIco
+n" id=
"sb_clock_8836"> </span></td>
<td class="sideColumn"> </td>
</tr>
<tr class="LeftLiContainer last" pair="8831" id="sb_pair_8831"
+ chart_link=
"/commodities/copper-streaming-chart">
<td class="sideColumn"> </td>
<td class="left bold first"><a href="/commodities/copper" ti
+tle=
"Koper">Koper</a></td>
<td class="lastNum" id="sb_last_8831">3.482</td>
<td class="chg redFont" id="sb_change_8831">-0.010</td>
<td class="chgPer redFont" id="sb_changepc_8831">-0.29%</td>
<td class="icon"><span class="newSiteIconsSprite redClockIco
+n" id=
"sb_clock_8831"> </span></td>
<td class="sideColumn"> </td>
</tr>
</tbody>
</table>
</body>
</html>
Prints:
Goud: 1670.75
Koper: 3.482
By the way I strongly advise you to always use strictures (use strict; use warnings;) and avoid global variables. There seems to be a bug in your code where you declare @comquotes in your sub, but use @quotes. In this case you maybe get away with it because in the code you don't show us most likely you assign the return value from comgetter to the global @quotes. But some time in the future that fortunate accident is going to turn around and bite you hard on the back side!
True laziness is hard work