while () { $line=; print $line; @array = split(/ /, $line); #split the line up into array so [0] is the id and [1] indel 1 etc. #print $array[0]; #print "\n"; foreach $indel (@array) #look at each indel in turn { next if $indel=~/>/; #skip the id @character = split(//, $indel); #look a character at a time foreach $char (@character) { if ($char=~/-/) { #if there is a gap add 1 to $count $count++; } } if($go==0) #if id hasnt been printed yet { print DATA3 "$array[0]"; print DATA3 "\n"; $go++; } @letter = qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); #converting numbers into letters A=0 etc. print DATA3 "$letter[$count]"; $count=0; } print DATA3 "\n"; $go=0; }