I want to take the resulting $name and $number arrays (I haven't pushed them into arrays yet, but you get the idea),

Is that a safe assumption to make? :-)
What for instance was @orf in your code?

Anyway try something like this:

my %averages; open DATA, "query.txt" or die "$!"; $/ = "\n"; while (<DATA>) { #split on consecutive sequences of spaces/tabs #i dont like naked splits.. personally... my ($key, $value) = split(" ",$_); $averages{$key}->[0]+= $value; $averages{$key}->[1]++; } map { $averages{$_}=$averages{$_}->[0]/$averages{$key}->[1]; $averages{$_}|=999; print "$key => $averages{$_}\n"; } keys %averages;
UPDATE: Fixed split call to read split(" ",$_) instead of split(/s+/,$_) Which isnt the same thing at all. Also read Hofmators excellent comment on this issue in this reply

Hope that helps.

Oh and you should in future indent your code properly, post your data and make no assumptions about what us the readers know understand or whatever about it and what you are trying to do.

Thats called pot luck. :-)

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)


In reply to Re: Removing multiple values by demerphq
in thread Removing multiple values by Evanovich

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.