I must have been wrong when I said:
I have also tried using $num (and the other variables used within the regexp) as package globals, with our, as well as with use vars, thinking that maybe lexical scoping was causing my pain. In so doing, I declared those variables at the top of the script to give them the broadest possible exposure. Again, no change; the second snippet fails, and the first snippet works great.

I guess I wasn't atomic/careful enough in my testing. In converting to globals I may have broken something else, because you're right; after re-testing, converting to globals makes the script work.

Based on your, and others' comments I dove back into perlre to see if I could find mention that lexicals are quirky when used within (?{...}) constructs. I didn't find any such warning, aside from the familiar "This feature is considered highly experimental", applied to the construct as a whole. Should this be submitted as a documentation patch? Is this topic addressed elsewhere in the POD?


Dave


In reply to Re^2: Inexplicable uninitialized value when using (?{...}) regexp construct. by davido
in thread Inexplicable uninitialized value when using (?{...}) regexp construct. by davido

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.