Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Find highest and lowest numerical values for columns in a file

by lidden (Deacon)
on Jun 24, 2011 at 17:14 UTC ( #911277=note: print w/ replies, xml ) Need Help??


in reply to Find highest and lowest numerical values for columns in a file

Go trough the file and remember what is the smallest and largest number in each column. Something like this (untested):

my $min_col_2 = 1_000_000; # Something large enough my $max_col_2 = 0; # Something small enough my $min_col_3 = 1_000_000; # Something large enough my $max_col_3 = 0; # Something small enough while(<>){ if(/^ZZ/){ my @array = split; if($min_col_2 > $array[1]){ $min_col_2 = $array[1]; } if($max_col_2 < $array[1]){ $max_col_2 = $array[1]; } # Snip } }

To get the step size you also have to remember the second smallest number, and look at the difference between that and the smallest when you are done.


Comment on Re: Find highest and lowest numerical values for columns in a file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://911277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2014-10-02 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls