See use, strict, warnings.
See perlsyn, perlre, my, push, grep, printf, sprintf.

use strict; use warnings; my (%items,@list); while(<DATA>) { my @l = $_ =~/(\d+)\s([\w\s]+?)\s+([\d,]+)/; push @list,$l[1]; $items{$l[1]}->{count} += $1; # bug? $l[2] =~s/,/./; $items{$l[1]}->{sum} += $l[2]; } my %s; for (grep {! $s{$_}++} @list) { $items{$_}->{sum} =~ s/\./,/; printf "%d % -9s %s\n", $items{$_}->{count},$_,$items{$_}->{sum}; } __DATA__ 1 PC BOX 20,0 1 PC Spare 32,0 1 PC Spare 5,2 1 PE Ak 100,0

This should get you started. Don't use this as is, understand and improve it. Add code to test whether the array @l is really populated (i.e. the match succeeds), for instance.
Convert your $ to cents and back, because you don't want floating point operations dealing which currency.
Why the is the "bug" comment in there?

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: Grouping of 2D arrays by shmem
in thread Grouping of 2D arrays by kfriman

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.