
johnny241088
Novice
Jan 14, 2013, 6:46 AM
Post #1 of 7
(395 views)
|
|
Problems at searching and counting
|
Can't Post
|
|
Heyho guys i have some trouble with my written script... i have a textfile and it looks like this: Chr1 phytozome8_0 exon 3631 3913 . + . ID=PAC:19656964.exon.1;Parent=PAC:19656964;pacid=19656964 Chr1 phytozome8_0 exon 3996 4276 . + . ID=PAC:19656964.exon.2;Parent=PAC:19656964;pacid=19656964 Chr1 phytozome8_0 exon 3631 3913 . + . ID=PAC:19656964.exon.3;Parent=PAC:19656964;pacid=19656964 and now i should extract the numbers after the word exon for each line, here my code: @ar = (""); $infile="test"; open (IN, "<", "$infile") || die "Cannot open file $infile: $!\n"; open (OUT, ">", "exontwice") || die "Cannot open file $outfile: $!\n"; while(<IN>) { push(@ar,$_); } foreach $zeile (@ar){ $startstop=substr($zeile,22,4); print "$startstop\n"; and now i try to print out the lines if $startstop (the numbers) are for two times in the array... and this is my try but i doesnt work can u help me??? rest of the code: foreach $line (@ar){ $count = () = @ar =~ /\Q$startstop\E/g; if ($count==2) { print OUT "$line"; } } } regards jOhnny
|