It turns out that $mode is what is undefined. Perl is reporting the wrong line number because it has optimized the entire if/elsif/else into a "case" (or "switch") statement.

Update: Well, the case/switch statement bit may or may not enter into it. I recall old documentation talking about simple if/elsif/else being internally optimized into a case/switch type of flow control. What I have been able to verify is that Perl is not recording line number of the elsif lines. One easy way to see this is:

perl -d script.pl DB<2> l 32-46 32: if($line =~ m/<!-- LHS movie -->/) { 33: $mode ="LHS"; 34: $moviecounter++; 35: $internal=0; 36 } elsif ($line =~ m/<!-- RHS movie -->/) { 37: $mode = "RHS"; 38: $moviecounter++; 39: $internal=0; 40 } elsif ($line =~ m/<!-- theater -->/) { 41: $mode = "theater"; 42: $counter++; 43: $moviecounter=-1; 44: $internal=0; 45 } elsif ($mode eq "LHS") { 46: if ($internal == 6 ) {
and notice that the elsif lines don't have colons (":") after their line numbers. This is probably worth bringing to the attention of p5p to see if it can be fixed.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: uninitialized weirdness by tye
in thread uninitialized weirdness by vaevictus

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.