Is "changing the number" different from "getting the right answer"? If I play with putting other references to "@-" in the script, I get way different behaviors too -- e.g.:
#!/usr/bin/perl
use strict;
use warnings;
my $string = "abc";
while( $string =~ /b/g ) {
print "@-\n";
}
produces:
*** malloc_zone_malloc[14337]: argument too large: 4294967280 Out of
+memory!
Putting other kinds of references to @- before the loop still gives me a wrong answer.
In my case, it seems like the only time I get the right output is when the script uses "$&" (update: I also get the right output when I use parens in the regex). Are you able to get a right answer without this?
If you just get different wrong outputs, I'd say this would be expected from a bug that is probably causing some uninitialized memory location to be used the wrong way, and the value you get can vary depending on the instructions being compiled. What matters are the conditions that distinguish correct output from wrong output.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.