#! perl -slw use strict; open MOTIFS, '<', '845226.motif' or die $!; my @motifs = ; close MOTIFS; chomp @motifs; open SEQS, '<', '845226.fasta' or die $!; while( my $seqID = ) { chomp $seqID; $seqID =~s[^>][]; my $seq = ''; { local $/ = ">"; chomp( $seq .= ); $seq =~ tr[\n][]d; } for my $motif ( @motifs ) { if( $seq =~ m[$motif([^A-Z]+)[A-Z]] ) { print "$seqID contains $motif; distance ", length( $1 ); } } } close SEQS; __END__ C:\test>845226 uc002yje.1 chr21:13973492-13976330 contains gccccac; distance 88 uc002yje.1 chr21:13973492-13976330 contains gccccac; distance 92 uc002yje.1 chr21:13973492-13976330 contains gggggaaaaaacc; distance 20 uc002yje.1 chr21:13973492-13976330 contains gccccac; distance 90 uc002yje.1 chr21:13973492-13976330 contains agagggccc; distance 4