in reply to max and min values in 3-column file
I need the script to give me as a result the line of S12 as the lowest column3 value
I presume you actually meant you want the later line in the event of ties. (Upd: No, I don't think that's what you meant. I don't understand what you do want, so I can't offer another solution. )
$_ = <>; my @fields = split; my $lowest = my $highest = $fields[2]; while (<>) { my @fields = split; if ($fields[2] <= $lowest) { $lowest = $fields[2]; } if ($fields[2] >= $highest) { $highest = $fields[2]; } } print("$lowest\n"); print("$highest\n");
|
|---|