#/usr/bin/perl @ARGV = ('test.txt'); open FILE, $ARGV[0] or die "can't open file\n"; $string = ''; @file = <FILE>; foreach $line(@file){ if ($line =~ /^>/){next;} else {$string .= $line;} } #the first line is useless so need to skip in close FILE; my $search = 'TTGACA'; $string =~ s/\s//g; #getting rid of whitespaces $n = ($string =~ tr/$search//); print "String $search occured $n times\n\n";
In reply to search for a sequence of chars in a string by imlou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |