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">&nbsp;</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">&nbsp;</span></td> <td class="sideColumn">&nbsp;</td> </tr> <tr class="LeftLiContainer" pair="8836" id="sb_pair_8836" char +t_link= "/commodities/silver-streaming-chart"> <td class="sideColumn">&nbsp;</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">&nbsp;</span></td> <td class="sideColumn">&nbsp;</td> </tr> <tr class="LeftLiContainer last" pair="8831" id="sb_pair_8831" + chart_link= "/commodities/copper-streaming-chart"> <td class="sideColumn">&nbsp;</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">&nbsp;</span></td> <td class="sideColumn">&nbsp;</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

In reply to Re: list separation by GrandFather
in thread list separation by robertw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.