Of the systems I've tried (macosx 10.3.9 w/perl 5.8.1; freebsd 5.4-STABLE/amd64 and 5.4-RC4/i386 both w/perl 5.8.6), the only one that came up with the right answer (0) was the amd64 box. Everywhere else, I got different values that are ridiculously large.

When I added "$&" to the print statement, I always got the right answer, so I would assume the problem lies with the optimization that applies when "$&" is not used.

Presumably, when perl compiles a script that does not use "$&", part of what is being optimized out involves allocating some resource that is needed to store or set @-.

(updated to make last paragraph easier to read)

Another update: after seeing davido's doubts about my conclusion, and even after replying to that, I have to admit he may have a point -- I tried one other mod to the OP script: add parens around "b" in the regex, and the problem goes away. So I'll guess that there is some logic that is invoked by the need to do a capture, or the need to handle $&, that will not be invoked when neither need arises, and (for some, maybe most, perl builds) this causes the problem with using @-. But that's just a guess, in hopes that it might help the perl source-code wonks to nail this thing.


In reply to Re: @- Bug on the loose, lets isolate it by graff
in thread @- Bug on the loose, lets isolate it 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.