in reply to How to group by a column and calculate max/min on another

Thanks to autovivication you could just add a hash or array inbetween. Here for example a hash:

push( @{ $gene_hash{$gene_key}{'start'} }, $start ); push( @{ $gene_hash{$gene_key}{'end'} }, $end ); .... my $Lowstart=min( @{$gene_hash{$key}{'start'} } );

By the way, if the data files are really big, it might be beneficial to find the minimums and maximums directly instead of first storing arrays of all the values. I.e. instead of pushing the value into an array while reading the file compare it to the last value stored there and if lower replace it. That way you store only three values per key instead of three arrays.

Replies are listed 'Best First'.
Re^2: How to group by a column and calculate max/min on another
by perl_paduan (Initiate) on Aug 03, 2010 at 14:08 UTC
    Thank you jethro!