You could also do something like:
sub mylineOK {
my ($line) = @_;
my @ebase = ("A","T");
my $limit = 15;
for ( @ebase ) {
my $cnt = ( $line =~ s/$_//g );
return 0 if ( $cnt >= $limit );
}
return 1;
}
Which will just count the number of times the ebase is stripped from the line.
Update:
All of these return the correct answer (in my very limited dataset). Here are some benchmarks.
Rate Original Moritz Tr m Strip
+ExplicitTr
Original 87.3/s -- -95% -97% -99% -99%
+ -100%
Moritz 1613/s 1748% -- -50% -74% -81%
+ -98%
Tr 3226/s 3596% 100% -- -48% -62%
+ -96%
m 6250/s 7060% 288% 94% -- -27%
+ -92%
Strip 8571/s 9720% 431% 166% 37% --
+ -89%
ExplicitTr 75000/s 85825% 4550% 2225% 1100% 775%
+ --
Note that explicit tr uses a hardcoded "A" and "T" in place of a variable.
(i.e. tr/A/A/ and tr/T/T/) The eval is what kills the performance. |