in reply to Need Help with reg ex
If I understand what you are trying to achieve then you can do it using a single regular expression match:
use strict; use warnings FATAL => 'all'; my $count1 = 0; my $line = do {local $/; <DATA>;}; $line =~ s/\n//g; while (($line =~ m/(?:aaggt){2}([atgcn]{100,})/ig)) { $count1++; print " $1\tcount1 \t $count1\n"; } __DATA__ aatgatgataaggtaaggtatgatgatgatgatgatagtagannnnnnnnnatgcatgaatgcaatgact +agcaatgac tagcaaggtaaggtaaggtaaggtaaggtatgatgatgannnnatgatgactagactgacaaggtaaggt +aaggtatga tgatgatcgatgacgat
As an aside, note that you should always use strictures (use strict; use warnings;). You should also use the three parameter version of open and use lexical file handles:
open my $inFile, '<', $fileName or die "cannot open $fileName: $!\n";
|
|---|