in reply to Removing multiple values
Is that a safe assumption to make? :-)
What for instance was @orf in your code?
Anyway try something like this:
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 replymy %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;
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Removing multiple values
by Hofmator (Curate) on Sep 07, 2001 at 18:35 UTC |