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


In reply to Re: Loop skipping by Sandy
in thread Loop skipping by ringleader

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.