imlou has asked for the wisdom of the Perl Monks concerning the following question:
#/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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search for a sequence of chars in a string
by Zaxo (Archbishop) on Sep 21, 2003 at 17:40 UTC | |
|
Re: search for a sequence of chars in a string
by tachyon (Chancellor) on Sep 21, 2003 at 17:35 UTC | |
|
Re: search for a sequence of chars in a string
by blokhead (Monsignor) on Sep 21, 2003 at 17:39 UTC |