http://www.perlmonks.org?node_id=814944


in reply to Parsing and Finding Max Min

You should definitely be using strict and warnings, for starters.

Next, do you really intend to update

$hash{$Query}[3] = $one; $hash{$Query}[4] = $two;
in all 4 blocks? That seems strange.

If you didn't intend that, what I'd suggest is modifying your code to simplify things - it would also make debugging simpler.

while (<FH>) { my ($Query, $Score, $Start, $End, $one, $two) = split; my $aref=[$Score, $Start, $End, $one, $two]; if ( ! exists ( $hash{$Query} ) ) { $hash{$Query} = $aref; } else { if ( $hash{$Query}[1] > $Start ) { $hash{$Query} = $aref; } } if ( ! exists ( $hash2{$Query} ) ) { $hash2{$Query}= $aref; } else { if ( $hash2{$Query}[2] < $End ) { $hash2{$Query} = $aref; } } }
That might make things a bit easier to debug...

Mike