I'm wondering if this is a bug in 5.8's handling of regex character classes, or whether it's just a case of the "perlre" man page being a bit off... (this applies to 5.8.0 and 5.8.1 equally)
Reading perlre, I would expect the following two regexes to match the same set of characters (in the ASCII range, at least), because they are said to be "equivalent":
/[[:punct:]]/
/\p{IsPunct}/
But when I tried the following little test snippet, I got a bit of a surprise:
for $x ( 0x20 .. 0x7e ) {
$_ = chr( $x );
$res = ( /[[:punct:]]/ ) ? "matches :punct:" : "is not a :punct:"
+;
$res .= ( /\p{IsPunct}/ ) ? " matches {IsPunct}" : " fails on {Is
+Punct}";
printf( " 0x%x (%3d.) %s %s\n", $x, $x, $_, $res ) if ( $res =~ /m
+atches/ );
}
Actually, when I look at the output, there seems to be some rhyme and reason to the discrepancies, so it looks like a "feature" (not a bug) to have the two different notions of "punctuation" (and the docs should be updated accordingly):
- [:punct:] -- the "posix" notion of punctuation -- is basically the same as
[^\x00-\x20\x7f\w] [^0-9A-Za-z\x00-\x20\x7f]
- \p{IsPunct} -- the "unicode" notion of punctuation -- refers to things that users of natural languages normally refer to as "punctuation", meaning things that you see/use in text for grouping or separating words in (usually) meaningful ways. (In this sense, it also extends to things outside the ASCII range.)
I wasn't sure which perl mailing list(s) I would post this to, so I decided to check here first.