in reply to Split Function - Positions

Perhaps something like this:
use strict; use warnings; use Data::Dumper; my @genes; my $screen = "ATCGATCGXXXXXATCGATXXXACTGCTACGGTACXXXAATTATXGCGCGXXT"; my @genes; while ( $screen =~ /([^X]+)/g ) { my $start = pos($screen) - length($1); push @genes, [$start, $1]; } print Dumper \@genes;

-enlil

Replies are listed 'Best First'.
Re: Re: Split Function - Positions
by duff (Parson) on Jun 02, 2004 at 03:01 UTC
    That's written simpler as:
    while ($screen =~ /([^X]+)/g) { push @genes, [ $-[0], $1 ]; }