in reply to Identifying Reverse Position of Specific Character in a String
Perhaps this'll be of use?
#!/usr/bin/perl -w use strict; use warnings; while (my $seq=<DATA>) { print $seq, ':'; my $cnt=0; my $prev=undef; my @arr = split /|/,$seq; while (my $c = shift @arr) { ++ $cnt; if ($c eq 'N') { $prev = $cnt; } else { print( $prev, ' ') if $prev; $prev = undef; } } print "\n"; } __DATA__ GNNTCGANNTT GAATCGNNNTT GANNCGNNNNN
On my machine, this gives me:
roboticus@swill ~/PerlMonks $ ./RevGap.pl GNNTCGANNTT :3 9 GAATCGNNNTT :9 GANNCGNNNNN :4 11
--roboticus
|
|---|