$similarity =0.25; $top = 0; open (IF, "matrix.a") or die "can't open input file"; open (OF, ">famlist25") or die "can't open output file"; $i=0; while(){ chomp; @temp=split ; $top = $temp[$i] * $similarity; push @cutoff, $top; for $j(0..($i-1)){ if ($temp[$j] > $cutoff[$i]){ push @row, $j;} } $list[$i][0]=$i; push @{$list[$i]},@row; for $k(0..($i-1)){ if ($temp[$k] > $cutoff[$k]){ push @{ $list[$k] } ,$i;} } undef @row; undef @temp; $i++;} close(IF); for $i (0..$#list){ for $y (0..$#{$list[$i]}){ print OF $list[$i][$y], " ";} print OF "\n"; } close(OF);