pabla23 has asked for the wisdom of the Perl Monks concerning the following question:
The program out of second "while" prints "$words[0]" not for one time (single row) but for a lot of time! I don't understand the reason! There is a solution? Can someone help me? Thanks Paolause strict; use warnings; use Data::Dumper; open (FILE, "/Users/Pabli/Desktop/gene_association.goa_human"); open (FILE2, "/Users/Pabli/Desktop/go3.obo"); $main::mio; $main::mio2; $main::mio4; $main::words2; my $i=0; my %go_accession_hash=(); while(<FILE>) { my @array_with_all_fields=split(/\t/); if ($array_with_all_fields[2] eq "TP53"){ $mio=$array_with_all_fields[4]; open my $out_file, '>>', 'myoutputfilename.txt' or die "$!"; #print "".$mio."\n"; print $out_file $mio; # print to file } } open (FILE3, "/Users/Pabli/Documents/workspace/PerlProva/myoutputfilen +ame.txt"); while($line=<FILE2>){ @words2 = split(" ",$line); #print "$words2[1]\n"; $i=5; while($line2=<FILE3>){ $i = $i - 1; if ($i >= 0) { @words = split(" ",$line2); } } print $words[0]."\n"; #if ($words2[0] eq "id:") { #$mio4=$words2[1]; #print $mio4."\n"; # } #elsif ($words2[0] eq "name:"){ #if ($mio4 == $mio2){ #print "name: ".$words2[1]."\n"; #} #} #} } close FILE; close FILE2; close FILE3;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: While problem
by marto (Cardinal) on Oct 27, 2014 at 09:38 UTC | |
by pabla23 (Novice) on Oct 27, 2014 at 09:59 UTC | |
by marto (Cardinal) on Oct 27, 2014 at 10:06 UTC | |
by Corion (Patriarch) on Oct 27, 2014 at 10:07 UTC | |
by Loops (Curate) on Oct 27, 2014 at 10:10 UTC | |
by pabla23 (Novice) on Oct 27, 2014 at 10:34 UTC | |
by Corion (Patriarch) on Oct 27, 2014 at 10:38 UTC | |
by Loops (Curate) on Oct 27, 2014 at 10:50 UTC |