1 2 3 4 5 6
if ($dnaseq=~m/aataaa/gi){ $pos = index($dnaseq, 'AATAAA'); substr($sigseq, $pos+5, 1, "P"); }
1 2 3 4 5 6 7 8 9 10 11 12 13
use strict; use warnings; my $pos = getPosition(0); while ($pos>=0) { print "Gefunden bei $pos\n"; $pos = getPosition($pos+1); } sub getPosition { my ($start) = @_; return index("xxAxxAxxxA", "A", $start); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#! /usr/bin/env perl use strict; use warnings; use 5.016; # Position 0 10 20 # | | | my $string = "123abc789def345abc901"; my $search = "abc"; my $length = length($search); while ( $string =~ m/$search/gi ) { say pos($string)-$length; } __END__
1 2 3 4
my $search = "AATAAA"; while ( $dnaseq =~ m/$search/gi ) { substr($sigseq, pos($dnaseq), 1, "P"); }