ringleader has asked for the wisdom of the Perl Monks concerning the following question:
for($m = 0; $m < scalar(@pathway_name); $m++) # foreach pathway name +given by an integer { print "Pathway is $pathway_name[$m]\n"; # e.g.pathway name is 1 for($j = 0; $j < $rows; $j++) # for each row in my 2- +D converted input file $file[][] { $n = 1; #print "Gene: $file[$j][0], Value: $file[$j][1]\n"; if($seen{$file[$j][0]}) # if the ind +exing element has already been seen { #print "Seen this Gene: $file[$j][0]\n"; # go on to t +he next row } elsif($file[$j][1]) # if the val +ue exists { $n = 1; VALUE:while($file[$j][$n] =~ /\b\.+\b/gi) # while the +re is still a digit there (i.e. not a name { #print "Gene: $file[$j][0], Value:$file[$j][$n]\n"; #print "Entering if statement in while block...\n"; if($file[$j][$n] =~ /\b\Q$pathway_name[$m]\E\.\d+/) # if +matches the combination of pathwayname.digit.digit { print OUTPUT "$file[$j][0]\t$pathway_name[$m]\n"; print "Gene: $file[$j][0], Value: $file[$j][$n] printed to o +utput file\n"; #print "Going to last value.\n"; $seen{$file[$j][0]} = 1; # add + the gene to the %seen hash for this pathway last VALUE; } else { #print "Gene: $file[$j][0], Value: $file[$j][$n] not matched +.\n"; $n++; # go + on to the next value } } # en +d while } # en +d elsif else { print "Skipped gene $file[$j][0]\n"; # g +o on to the next line } } # end + while ($j < $row) undef %seen; # since + going on to the next pathway, undefine %seen }
janitored by ybiC: Balanced <code> tags around longish codeblock, for less vertical scrolling
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop skipping
by bgreenlee (Friar) on Aug 11, 2004 at 15:08 UTC | |
by ringleader (Acolyte) on Aug 11, 2004 at 15:48 UTC | |
by husker (Chaplain) on Aug 11, 2004 at 15:54 UTC | |
by ringleader (Acolyte) on Aug 11, 2004 at 16:18 UTC | |
|
Re: Loop skipping
by Solo (Deacon) on Aug 11, 2004 at 17:39 UTC | |
|
Re: Loop skipping
by Sandy (Curate) on Aug 11, 2004 at 20:22 UTC | |
by ringleader (Acolyte) on Aug 12, 2004 at 08:20 UTC | |
|
Re: Loop skipping
by johnnywang (Priest) on Aug 11, 2004 at 19:27 UTC |