My best guess as to your meaning is that column 1 is the frequency of the value in column 3.
Here's one way that might be coded:
#! perl -slw use strict; my @data; push @data, [ split ] while <DATA>; @data = sort { $a->[ 0 ] * $a->[ 2 ] <=> $b->[ 0 ] * $b->[ 2 ] } @data; print "Lowest: ". join "\t", @{ $data[ 0 ] }; print "Highest:", join "\t", @{ $data[-1 ] }; __DATA__ 2870 S11 1 574 S11 2 317 S11 3 31 S11 4 1 S11 6 1 S11 7 2925 S12 1 8 S12 5 1 S12 6 1 S12 9
And the output is:
c:\test>junk37 Lowest: 1 S11 6 Highest:2925 S12 1
As both groups of data have 1 x 6 values, either (or both) are candidates for the 'lowest', so you'll have to decide which through some further qualification to the sort: eg. you might consider that in the event of a tie S11 is 'lower' than S12. Or, you might decide to display both (all) equally low values.
Of course, if the set of values is large, especially if it is larger than memory, sorting is an inefficient way of find the largest and smallest. The main point is that (assuming I understood you correctly) that you need to multiply column 1 by column 3 when doing your comparisons.
Feel free to ask questions about this code. It is easier to answer specific questions than guess what you might not know.
In reply to Re: max and min values in 3-column file
by BrowserUk
in thread max and min values in 3-column file
by perldummie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |