argra****@users*****
argra****@users*****
2014年 9月 28日 (日) 05:21:29 JST
Index: docs/perl/5.18.1/perldata.pod diff -u docs/perl/5.18.1/perldata.pod:1.1 docs/perl/5.18.1/perldata.pod:1.2 --- docs/perl/5.18.1/perldata.pod:1.1 Sat Aug 24 17:14:45 2013 +++ docs/perl/5.18.1/perldata.pod Sun Sep 28 05:21:28 2014 @@ -273,6 +273,18 @@ =end original +Up until Perl 5.18, the actual rules of what a valid identifier +was were a bit fuzzy. However, in general, anything defined here should +work on previous versions of Perl, while the opposite -- edge cases +that work in previous versions, but aren't defined here -- probably +won't work on newer versions. +As an important side note, please note that the following only applies +to bareword identifiers as found in Perl source code, not identifiers +introduced through symbolic references, which have much fewer +restrictions. +If working under the effect of the C<use utf8;> pragma, the following +rules apply: +(TBT) / (?[ ( \p{Word} & \p{XID_Start} ) + [_] ]) \p{XID_Continue}* /x @@ -283,6 +295,9 @@ =end original +If not under C<use utf8>, the source is treated as ASCII + 128 extra +controls, and identifiers should match +(TBT) / (?aa) (?!\d) \w+ /x @@ -293,6 +308,9 @@ =end original +That is, any word character in the ASCII range, as long as the first +character is not a digit. +(TBT) =begin original @@ -305,6 +323,13 @@ =end original +There are two package separators in Perl: A double colon (C<::>) and a single +quote (C<'>). Normal identifiers can start or end with a double colon, and +can contain several parts delimited by double colons. +Single quotes have similar rules, but with the exception that they are not +legal at the end of an identifier: That is, C<$'foo> and C<$foo'bar> are +legal, but C<$foo'bar'> are not. +(TBT) =begin original @@ -318,6 +343,14 @@ =end original +Finally, if the identifier is preceded by a sigil -- +More so, normal identifiers can start or end with any number +of double colons (::), and can contain several parts delimited +by double colons. +And additionally, if the identifier is preceded by a sigil -- +that is, if the identifier is part of a variable name -- it +may optionally be enclosed in braces. +(TBT) =begin original @@ -327,6 +360,10 @@ =end original +While you can mix double colons with singles quotes, the quotes must come +after the colons: C<$::::'foo> and C<$foo::'bar> are legal, but C<$::'::foo> +and C<$foo'::bar> are not. +(TBT) =begin original @@ -334,6 +371,8 @@ =end original +Put together, a grammar to match a basic identifier becomes +(TBT) / (?(DEFINE) @@ -371,6 +410,11 @@ =end original +Meanwhile, special identifiers don't follow the above rules; For the most +part, all of the identifiers in this category have a special meaning given +by Perl. Because they have special parsing rules, these generally can't be +fully-qualified. They come in four forms: +(TBT) =over