my $dna = 'gctagctgatgctagcagcagcatgtagctagctgacga'; for my $strand (@fragment) { my $pos = index($dna, $strand); next if $pos == -1; my $pad = ' ' x $pos; print $pad, $strand, "\n"; }