in reply to Loop skipping

To re-iterate previous posts, it would be easier if we could see the actual construct of the @file

However...

based on the comments that go along with your code, there are possibly two flaws:

VALUE:while($file[$j][$n] =~ /\b\.+\b/gi) # while ther +e is still a digit there (i.e. not a name
This does not do what it says. The condition will satisfy values of the form "word.word" where the period really is a period! It will satisyfy "1.2" because "1" is a word, and "2" is a word. It will NOT satisfy the number "99", and thus stop checking this gene altogether (even if there are more numbers after it). '99' will never satisfy the while condition!

Secondly, the g modifier to your regular expression keeps track of the last position of the regular expression when it matched your variable.

So the first time it tries to match $file[1][1] it matches, and puts it position reminder at the end of the string. When "pathway" is set to "2", and it tries to match $file[1][1] again, it starts at the end of the value, and returns false, never to test any of the other values.

So, with the assumption that @file looks like (one value per $file[$row][$n]), and not that I also added a few more test conditions to your input data,

my @file; push @{$file[0]}, qw (YAL038W 1.1 2.4 4.1 YCL040W 99.2 1.1 1.6 1.8 9.11 0.040212811); push @{$file[1]}, qw(YDR223W 99 4.7 0.0085523710); push @{$file[2]}, qw(YDL188C 1.5.4 10.3.1 13.32 YGL134W 01.05.04 02.19 0.083130297); $rows = 3; my %seen; @pathway_name = (1, 2, 4, 99);

then I changed your VALUE:while... statement to: (notice I got rid of the gi qualifiers).

VALUE:while($file[$j][$n] =~ /^[\.\d ]+$/)
My results are: (do not expect 99 to satisfy your condition of digit.digit in a later if statement.
Pathway is 1 Gene: YAL038W, Value: 1.1 printed to output file Gene: YDL188C, Value: 1.5.4 printed to output file Pathway is 2 Gene: YAL038W, Value: 2.4 printed to output file Pathway is 4 Gene: YAL038W, Value: 4.1 printed to output file Gene: YDR223W, Value: 4.7 printed to output file Pathway is 99
Hopes this helps,

Sandy

Replies are listed 'Best First'.
Re^2: Loop skipping
by ringleader (Acolyte) on Aug 12, 2004 at 08:20 UTC
    You're right Sandy.
    I removed the g modifier about five minutes before you posted, and it worked.

    Nice job, lads :-D
    It's always something stupidly small with my code...
    Thanks for all the help; conversely, sorry bout all the headaches!