http://www.perlmonks.org?node_id=1003279


in reply to Pattern Searching

I must be missing something obvious, but I can reproduce the basics of your output by a few nested loops and a regex.
use Modern::Perl; my @patterns = qw/GAATTC CCWGG/; while ( my $sequence = <DATA> ) { my @matches; while ( $sequence =~ m/($patterns[0]|$patterns[1])/g ) { for my $expr ( 1 .. $#- ) { push @matches, $-[$expr] .. $+[$expr] - 1; } } say "@matches"; } __DATA__ GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC
Output:
0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65 0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65 0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Pattern Searching
by Anonymous Monk on Nov 12, 2012 at 15:34 UTC
    Thanks to all of you. I have solved my problem.I learn many things from you people. Now I have to call java code by using the Perl. Can you provide me some example or a link which thoroughly cover this.
      Your question is not related to the previous one. Please, start a new thread.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ