Hey Guys. This is so frustrating. I added some code as suggested:
push( @next_cell_arr, $protein_matrix[$row][$col+1] );# - note: 'right +' cell is first element of array push( @next_cell_arr, $protein_matrix[$row+1][$col+1] );# - no +te: 'diagonal' cell is second element of array push( @next_cell_arr, $protein_matrix[$row+1][$col] );# - note +: 'bottom' cell is third element of array # - debug $arr_len = scalar @next_cell_arr; for( $var = 0; $var < $arr_len; $var++ ){ print $next_cell_arr[$var]; print "\n"; } print "\n\n"; #exit; # - debug # - if all values are equal, then the sequence gets a match of + suffers a mismatch (diagonal move), and not a gap penalty. This als +o saves me from having to compute the max of the three cells my $val1 = $next_cell_arr[0] || die "val1 is undefined!!\n"; my $val2 = $next_cell_arr[1] || die "val2 is undefined!!\n"; my $val3 = $next_cell_arr[2] || die "val3 is undefined!!\n";
When I run my code, $val1 is indeed not being defined, but the debug loop, right above, $next_cell_arr[0] is displaying the correct value. This makes absolutely no sense to me. Something so incredibly simple is not working here. EDIT: By the way, I always use the -w flag, but adding 'use warnings' might be easier

In reply to Re: Understanding variable scope in perl by BioBoy
in thread Understanding variable scope in perl by BioBoy

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.