This is some weird stuff, but I'm confused. Does the name of the variable ($re_bad) imply that expression typed by the programmer is bad, or are you saying that this should be considered an okay expression, and perl just seems to be doing something bad to it?

I wonder, because this part:  [A-Z$#@_#] seems to be specifying "#" twice within a character class, which seems odd (should be harmless, granted, but odd). The "qr" operator is being used with single-quote delimiters, so the "@_" is being taken literally, rather than being interpolated (was that your intention?). When some other delimiter is used, the result is different: with nothing else in the script, "@_" is empty, so it seems to interpolate as an empty string in this case.

I tried both ways, on both my home linux and my office solaris 5.8, and got results that were not identical, but equivalent, and worrisome in all cases. Feeding Data::Dumper's output through something like "od" helps to see the issue:

solaris5.8 $ test.perl | od -t ax1 0000000 $ V A R 1 sp = sp q r / ( ? x - +i 24 56 41 52 31 20 3d 20 71 72 2f 28 3f 78 2d +69 0000020 s m : @ @ ( [ A - Z $ # @ _ # +] 73 6d 3a 40 40 28 5b 41 2d 5a 24 23 40 5f 23 +5d 0000040 * ) sp ( ? ! sp [ A - Z a - z 0 +- 2a 29 20 28 3f 21 20 5b 41 2d 5a 61 2d 7a 30 +2d 0000060 9 $ # @ _ ] sp ) nul nul lf ) / ; lf 39 24 23 40 5f 5d 20 29 00 00 0a 29 2f 3b 0a
Note the null bytes. Is it supposed do that? I happened to get the exact same results on linux for this case.

Now, if I change the delimiters on "qr" to something else (like slashes), which allows the "@_" to interpolate, the two systems do seem to differ:

solaris5.8 $ test-slashes.perl | od -t ax1 0000000 $ V A R 1 sp = sp q r / ( ? x - +i 24 56 41 52 31 20 3d 20 71 72 2f 28 3f 78 2d +69 0000020 s m : @ @ ( [ A - Z # ] * ) sp +( 73 6d 3a 40 40 28 5b 41 2d 5a 23 5d 2a 29 20 +28 0000040 ? ! sp [ A - Z a - z 0 - 9 $ # +@ 3f 21 20 5b 41 2d 5a 61 2d 7a 30 2d 39 24 23 +40 0000060 _ ] sp ) can lf ) / ; lf 5f 5d 20 29 18 0a 29 2f 3b 0a ##### linux2.4 $ test-slashes.perl | od -t ax1 0000000 $ V A R 1 sp = sp q r / ( ? x - +i 24 56 41 52 31 20 3d 20 71 72 2f 28 3f 78 2d +69 0000020 s m : @ @ ( [ A - Z # ] * ) sp +( 73 6d 3a 40 40 28 5b 41 2d 5a 23 5d 2a 29 20 +28 0000040 ? ! sp [ A - Z a - z 0 - 9 $ # +@ 3f 21 20 5b 41 2d 5a 61 2d 7a 30 2d 39 24 23 +40 0000060 _ ] sp ) s lf ) / ; lf 5f 5d 20 29 73 0a 29 2f 3b 0a
Where solaris had one garbage character (0x18), linux had a different character ("s"), which on the surface looks plausible, but is garbage nonetheless, I expect (e.g. it's whatever happens to have been at some point in core when a C function happens to step past the boundary of an array).

Also, it seems that only the first instance of "@_" was interpolated -- if that makes sense, I need to read perlre again, much more carefully...


In reply to Re: Worrying regex issue with 5.8.0 by graff
in thread Worrying regex issue with 5.8.0 by ruscoekm

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.