in reply to counting gene regions

this code does the same: :)

sub catch_exons2 { my @res; push @res, [substr($1, 0, 1), length $1] while $_[0] =~ /(a+|x+)/g +; return @res; }

Upd or even without a sub:

$string = 'aaaaxxxaxaxaaaaaaaxxxxxxxxxxaax'; @regions = map { [substr($_, 0, 1), length $_] } $string =~ /(a+|x+)/g +;

Update: s/\$1/\$_/g in the last onliner

Replies are listed 'Best First'.
Re^2: counting gene regions
by tucano (Scribe) on Jul 22, 2004 at 08:52 UTC
    realy cool and sintetic, i will update my code soon!
    I know, i write a lot :-)!