From: Gurusamy Sarathy Date: Thu, 1 Jun 2000 08:24:40 +0000 (+0000) Subject: further qualify references to "alphanumeric" (from Wolfgang Laun X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f1cbbd6ecad59f8e4d9d331daa6642ebfd972ae1;p=p5sagit%2Fp5-mst-13.2.git further qualify references to "alphanumeric" (from Wolfgang Laun ) p4raw-id: //depot/perl@6186 --- diff --git a/handy.h b/handy.h index 81f4745..de0fa57 100644 --- a/handy.h +++ b/handy.h @@ -261,7 +261,7 @@ C). /* =for apidoc Am|bool|isALNUM|char ch Returns a boolean indicating whether the C C is an ASCII alphanumeric -character or digit. +character (including underscore) or digit. =for apidoc Am|bool|isALPHA|char ch Returns a boolean indicating whether the C C is an ASCII alphabetic diff --git a/pod/perlapi.pod b/pod/perlapi.pod index cd467ba..2532620 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -670,7 +670,7 @@ Undefines the hash. =item isALNUM Returns a boolean indicating whether the C C is an ASCII alphanumeric -character or digit. +character (including underscore) or digit. bool isALNUM(char ch) diff --git a/pod/perldata.pod b/pod/perldata.pod index ac444fa..a2bb840 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -303,7 +303,8 @@ price is $Z<>100." print "The price is $Price.\n"; # interpreted As in some shells, you can enclose the variable name in braces to -disambiguate it from following alphanumerics. You must also do +disambiguate it from following alphanumerics (and underscores). +You must also do this when interpolating a variable into a string to separate the variable name from a following double-colon or an apostrophe, since these would be otherwise treated as a package separator: diff --git a/pod/perlfaq6.pod b/pod/perlfaq6.pod index bf007ee..29136ab 100644 --- a/pod/perlfaq6.pod +++ b/pod/perlfaq6.pod @@ -415,7 +415,8 @@ Use the split function: Note that this isn't really a word in the English sense; it's just chunks of consecutive non-whitespace characters. -To work with only alphanumeric sequences, you might consider +To work with only alphanumeric sequences (including underscores), you +might consider while (<>) { foreach $word (m/(\w+)/g) { diff --git a/pod/perlfaq9.pod b/pod/perlfaq9.pod index 16a803c..d1bd593 100644 --- a/pod/perlfaq9.pod +++ b/pod/perlfaq9.pod @@ -215,7 +215,8 @@ Here's an example of decoding: $string =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge; Encoding is a bit harder, because you can't just blindly change -all the non-alphanumunder character (C<\W>) into their hex escapes. +all characters that are not letters, digits or underscores (C<\W>) +into their hex escapes. It's important that characters with special meaning like C and C I be translated. Probably the easiest way to get this right is to avoid reinventing the wheel and just use the URI::Escape module, diff --git a/pod/perllocale.pod b/pod/perllocale.pod index 55ccf44..ddb5a6e 100644 --- a/pod/perllocale.pod +++ b/pod/perllocale.pod @@ -449,7 +449,7 @@ if you "use locale". a A b B c C d D e E a b c d e A B C D E -Here is a code snippet to tell what alphanumeric +Here is a code snippet to tell what "word" characters are in the current locale, in that locale's order: use locale; @@ -518,8 +518,9 @@ results, and so always obey the current C locale. In the scope of S>, Perl obeys the C locale setting. This controls the application's notion of which characters are alphabetic. This affects Perl's C<\w> regular expression metanotation, -which stands for alphanumeric characters--that is, alphabetic and -numeric characters. (Consult L for more information about +which stands for alphanumeric characters--that is, alphabetic, +numeric, and including other special characters such as the underscore or +hyphen. (Consult L for more information about regular expressions.) Thanks to C, depending on your locale setting, characters like 'E', 'E', 'E', and 'E' may be understood as C<\w> characters. diff --git a/pod/perlre.pod b/pod/perlre.pod index a82ab32..15e58c1 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -254,15 +254,15 @@ backspace are control characters. All characters with ord() less than =item graph -Any alphanumeric or punctuation character. +Any alphanumeric or punctuation (special) character. =item print -Any alphanumeric or punctuation character or space. +Any alphanumeric or punctuation (special) character or space. =item punct -Any punctuation character. +Any punctuation (special) character. =item xdigit @@ -381,6 +381,7 @@ use for a pattern. Simply quote all non-"word" characters: $pattern =~ s/(\W)/\\$1/g; +(If C is set, then this depends on the current locale.) Today it is more common to use the quotemeta() function or the C<\Q> metaquoting escape sequence to disable all metacharacters' special meanings like this: