in reply to Re: search and print in perl
in thread search and print in perl

Thanks. My input.txt is like the following: TGGTACGACCGAACGAAAGAAAAAGAACACACACTGACCGGAGGGGTTGAATTGTTTGCCTGGCAC it goes on like this, Random ACGT characters for whole 6 lines.

Replies are listed 'Best First'.
Re^3: search and print in perl
by almut (Canon) on Jun 01, 2009 at 12:09 UTC

    Could you provide a sample of a subsequence that is supposed to match (there is no TATAAT in this sample)?  Also, may the subsequences in question be split across more than one line? In this case, you would need to chomp the input lines to get rid of the newlines in your $text (as you're not accounting for them in the regex).

    Also, if your input is then all on one line, you probably want non-greedy matching ([ACGT]+?) of the parts in between the strings of interest, or else they'll gobble up more than you want...

Re^3: search and print in perl
by citromatik (Curate) on Jun 01, 2009 at 12:11 UTC
    it goes on like this, Random ACGT characters for whole 6 lines

    If the input is multi-line and you have to match your regexp against the full input (all lines concatenated), then you should strip off the newlines characters of each individual line:

    while($line = <IN>) { chomp $line; ## <---- !!! $text .= $line; }

    citromatik