in reply to Worrying regex issue with 5.8.0
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:
Note the null bytes. Is it supposed do that? I happened to get the exact same results on linux for this case.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
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:
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).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
Also, it seems that only the first instance of "@_" was interpolated -- if that makes sense, I need to read perlre again, much more carefully...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Worrying regex issue with 5.8.0
by ruscoekm (Monk) on Nov 15, 2002 at 08:21 UTC |