#! /usr/bin/perl -w use strict; my $screen = "ATCGATCGXXXXXATCGATXXXACTGCTACGGTACXXXAATTATXGCGCGXXT"; my @chars = split //, $screen; my @starts; foreach ( 0 .. scalar @chars - 1 ) { push @starts, $_ if $chars[$_] ne 'X' && ( 0 == $_ || $chars[$_-1] eq 'X' ); } print "$screen\n@starts\n";