In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/46f8a5eafc5328639a1c6ff58ff2407a39b09c04?hp=ee2276e59a3c027cb89c721d866c9db4ba683a7b>
- Log ----------------------------------------------------------------- commit 46f8a5eafc5328639a1c6ff58ff2407a39b09c04 Author: Father Chrysostomos <[email protected]> Date: Mon Sep 22 22:47:55 2014 -0700 Consistent spaces after dots in perlop M pod/perlop.pod commit bb1efdce4c120f5570738ad0b7fe2c9b5a4b218b Author: Father Chrysostomos <[email protected]> Date: Mon Sep 22 22:09:34 2014 -0700 Add GPFLAGS and GPf_* to B M ext/B/B.xs M ext/B/Makefile.PL M ext/B/t/b.t ----------------------------------------------------------------------- Summary of changes: ext/B/B.xs | 4 ++ ext/B/Makefile.PL | 2 +- ext/B/t/b.t | 6 +++ pod/perlop.pod | 116 ++++++++++++++++++++++++++++-------------------------- 4 files changed, 71 insertions(+), 57 deletions(-) diff --git a/ext/B/B.xs b/ext/B/B.xs index 15cadaf..bc423cc 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1799,6 +1799,10 @@ U32 GvLINE(gv) B::GV gv +U32 +GvGPFLAGS(gv) + B::GV gv + void FILEGV(gv) B::GV gv diff --git a/ext/B/Makefile.PL b/ext/B/Makefile.PL index 308b015..81f6826 100644 --- a/ext/B/Makefile.PL +++ b/ext/B/Makefile.PL @@ -30,7 +30,7 @@ my @names = ({ name => 'HEf_SVKEY', macro => 1, type => "IV" }, # match the pattern below. foreach my $tuple (['cop.h'], ['cv.h', 'CVf'], - ['gv.h', 'GVf'], + ['gv.h', 'G[PV]f'], ['op.h'], ['opcode.h', 'OPp'], ['op_reg_common.h','(?:(?:RXf_)?PMf_)'], diff --git a/ext/B/t/b.t b/ext/B/t/b.t index 271eb37..7bdd87c 100644 --- a/ext/B/t/b.t +++ b/ext/B/t/b.t @@ -203,6 +203,12 @@ is($gv_ref->SAFENAME(), "gv", "Test SAFENAME()"); like($gv_ref->FILE(), qr/b\.t$/, "Testing FILE()"); is($gv_ref->SvTYPE(), B::SVt_PVGV, "Test SvTYPE()"); is($gv_ref->FLAGS() & B::SVTYPEMASK, B::SVt_PVGV, "Test SVTYPEMASK"); +is($gv_ref->GPFLAGS & B::GPf_ALIASED_SV, 0, 'GPFLAGS are unset'); +{ + local *gv = \my $x; + is($gv_ref->GPFLAGS & B::GPf_ALIASED_SV, B::GPf_ALIASED_SV, + 'GPFLAGS gets GPf_ALIASED_SV set'); +} # The following return B::SPECIALs. is(ref B::sv_yes(), "B::SPECIAL", "B::sv_yes()"); diff --git a/pod/perlop.pod b/pod/perlop.pod index c36d8ce..52eb968 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -6,14 +6,14 @@ perlop - Perl operators and precedence =head1 DESCRIPTION In Perl, the operator determines what operation is performed, -independent of the type of the operands. For example C<$a + $b> +independent of the type of the operands. For example C<$a + $b> is always a numeric addition, and if C<$a> or C<$b> do not contain numbers, an attempt is made to convert them to numbers first. This is in contrast to many other dynamic languages, where the -operation is determined by the type of the first argument. It also +operation is determined by the type of the first argument. It also means that Perl has two versions of some operators, one for numeric -and one for string comparison. For example C<$a == $b> compares +and one for string comparison. For example C<$a == $b> compares two numbers for equality, and C<$a eq $b> compares two strings. There are a few exceptions though: C<x> can be either string @@ -170,8 +170,8 @@ value. print ++$j; # prints 1 Note that just as in C, Perl doesn't define B<when> the variable is -incremented or decremented. You just know it will be done sometime -before or after the value is returned. This also means that modifying +incremented or decremented. You just know it will be done sometime +before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behavior. Avoid statements like: @@ -203,7 +203,7 @@ The auto-decrement operator is not magical. X<**> X<exponentiation> X<power> Binary "**" is the exponentiation operator. It binds even more -tightly than unary minus, so -2**4 is -(2**4), not (-2)**4. (This is +tightly than unary minus, so -2**4 is -(2**4), not (-2)**4. (This is implemented using C's pow(3) function, which actually works on doubles internally.) @@ -222,7 +222,7 @@ with a plus or minus, a string starting with the opposite sign is returned. One effect of these rules is that -bareword is equivalent to the string "-bareword". If, however, the string begins with a non-alphabetic character (excluding "+" or "-"), Perl will attempt to convert -the string to a numeric and the arithmetic negation is performed. If the +the string to a numeric and the arithmetic negation is performed. If the string cannot be cleanly converted to a numeric, Perl will give the warning B<Argument "the string" isn't numeric in negation (-) at ...>. X<-> X<negation, arithmetic> @@ -271,7 +271,8 @@ examples using these operators. If the right argument is an expression rather than a search pattern, substitution, or transliteration, it is interpreted as a search pattern at run -time. Note that this means that its contents will be interpolated twice, so +time. Note that this means that its +contents will be interpolated twice, so '\\' =~ q'\\'; @@ -476,8 +477,8 @@ Binary "<=>" returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument. If your platform supports NaNs (not-a-numbers) as numeric values, using them with "<=>" returns undef. NaN is not "<", "==", ">", -"<=" or ">=" anything (even NaN), so those 5 return false. NaN != NaN -returns true, as does NaN != anything else. If your platform doesn't +"<=" or ">=" anything (even NaN), so those 5 return false. NaN != NaN +returns true, as does NaN != anything else. If your platform doesn't support NaNs then NaN is just a string with numeric value 0. X<< <=> >> X<spaceship> @@ -725,7 +726,7 @@ That because the corresponding position in C<@a> contains an array that (eventually) has a 4 in it. Smartmatching one hash against another reports whether both contain the -same keys, no more and no less. This could be used to see whether two +same keys, no more and no less. This could be used to see whether two records have the same field names, without caring what values those fields might have. For example: @@ -763,8 +764,8 @@ C<when> clause. See the section on "Switch Statements" in L<perlsyn>. To avoid relying on an object's underlying representation, if the smartmatch's right operand is an object that doesn't overload C<~~>, it raises the exception "C<Smartmatching a non-overloaded object -breaks encapsulation>". That's because one has no business digging -around to see whether something is "in" an object. These are all +breaks encapsulation>". That's because one has no business digging +around to see whether something is "in" an object. These are all illegal on objects without a C<~~> overload: %hash ~~ $object @@ -772,7 +773,8 @@ illegal on objects without a C<~~> overload: "fred" ~~ $object However, you can change the way an object is smartmatched by overloading -the C<~~> operator. This is allowed to extend the usual smartmatch semantics. +the C<~~> operator. This is allowed to +extend the usual smartmatch semantics. For objects that do have an C<~~> overload, see L<overload>. Using an object as the left operand is allowed, although not very useful. @@ -858,16 +860,17 @@ Although it has no direct equivalent in C, Perl's C<//> operator is related to its C-style or. In fact, it's exactly the same as C<||>, except that it tests the left hand side's definedness instead of its truth. Thus, C<< EXPR1 // EXPR2 >> returns the value of C<< EXPR1 >> if it's defined, -otherwise, the value of C<< EXPR2 >> is returned. (C<< EXPR1 >> is evaluated -in scalar context, C<< EXPR2 >> in the context of C<< // >> itself). Usually, +otherwise, the value of C<< EXPR2 >> is returned. +(C<< EXPR1 >> is evaluated in scalar context, C<< EXPR2 >> +in the context of C<< // >> itself). Usually, this is the same result as C<< defined(EXPR1) ? EXPR1 : EXPR2 >> (except that the ternary-operator form can be used as a lvalue, while C<< EXPR1 // EXPR2 >> -cannot). This is very useful for +cannot). This is very useful for providing default values for variables. If you actually want to test if at least one of C<$a> and C<$b> is defined, use C<defined($a // $b)>. The C<||>, C<//> and C<&&> operators return the last value evaluated -(unlike C's C<||> and C<&&>, which return 0 or 1). Thus, a reasonably +(unlike C's C<||> and C<&&>, which return 0 or 1). Thus, a reasonably portable way to find out the home directory might be: $home = $ENV{HOME} @@ -913,7 +916,7 @@ operators depending on the context. In list context, it returns a list of values counting (up by ones) from the left value to the right value. If the left value is greater than the right value then it returns the empty list. The range operator is useful for writing -C<foreach (1..10)> loops and for doing slice operations on arrays. In +C<foreach (1..10)> loops and for doing slice operations on arrays. In the current implementation, no temporary array is created when the range operator is used as the expression in C<foreach> loops, but older versions of Perl might burn a lot of memory when you write something @@ -928,15 +931,15 @@ auto-increment, see below. In scalar context, ".." returns a boolean value. The operator is bistable, like a flip-flop, and emulates the line-range (comma) -operator of B<sed>, B<awk>, and various editors. Each ".." operator +operator of B<sed>, B<awk>, and various editors. Each ".." operator maintains its own boolean state, even across calls to a subroutine -that contains it. It is false as long as its left operand is false. +that contains it. It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, I<AFTER> which the range operator becomes false again. It doesn't become false till the next time the range operator is evaluated. It can test the right operand and become false on the same evaluation it became true (as in B<awk>), but it still returns -true once. If you don't want it to test the right operand until the +true once. If you don't want it to test the right operand until the next evaluation, as in B<sed>, just use three dots ("...") instead of two. In all other regards, "..." behaves just like ".." does. @@ -1004,7 +1007,7 @@ the two range operators: } } -This program will print only the line containing "Bar". If +This program will print only the line containing "Bar". If the range operator is changed to C<...>, it will also print the "Baz" line. @@ -1171,7 +1174,7 @@ The C<< => >> operator is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, -constants, single number v-strings or function calls. If in doubt about +constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly. Otherwise, the C<< => >> operator behaves exactly as the comma operator @@ -1290,7 +1293,7 @@ Address-of operator. (But see the "\" operator for taking a reference.) =item unary * -Dereference-address operator. (Perl's prefix dereferencing +Dereference-address operator. (Perl's prefix dereferencing operators are typed: $, @, %, and &.) =item (TYPE) @@ -1339,7 +1342,7 @@ Note, however, that this does not always work for quoting Perl code: $s = q{ if($a eq "}") ... }; # WRONG -is a syntax error. The C<Text::Balanced> module (standard as of v5.8, +is a syntax error. The C<Text::Balanced> module (standard as of v5.8, and from CPAN before then) is able to do this properly. There can be whitespace between the operator and the quoting @@ -1379,7 +1382,7 @@ X<\o{}> The result is the character specified by the hexadecimal number between the braces. See L</[8]> below for details on which character. -Only hexadecimal digits are valid between the braces. If an invalid +Only hexadecimal digits are valid between the braces. If an invalid character is encountered, a warning will be issued and the invalid character and all subsequent characters (valid or invalid) within the braces will be discarded. @@ -1594,8 +1597,8 @@ is equivalent to For the pattern of regex operators (C<qr//>, C<m//> and C<s///>), the quoting from C<\Q> is applied after interpolation is processed, -but before escapes are processed. This allows the pattern to match -literally (except for C<$> and C<@>). For example, the following matches: +but before escapes are processed. This allows the pattern to match +literally (except for C<$> and C<@>). For example, the following matches: '\s\t' =~ /\Q\s\t/ @@ -1629,8 +1632,8 @@ This operator quotes (and possibly compiles) its I<STRING> as a regular expression. I<STRING> is interpolated the same way as I<PATTERN> in C<m/PATTERN/>. If "'" is used as the delimiter, no interpolation is done. Returns a Perl value which may be used instead of the -corresponding C</STRING/msixpodual> expression. The returned value is a -normalized version of the original pattern. It magically differs from +corresponding C</STRING/msixpodual> expression. The returned value is a +normalized version of the original pattern. It magically differs from a string containing the same characters: C<ref(qr/x/)> returns "Regexp"; however, dereferencing it is not well defined (you currently get the normalized version of the original pattern, but this may change). @@ -1734,7 +1737,7 @@ you can use any pair of non-whitespace (ASCII) characters as delimiters. This is particularly useful for matching path names that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is the delimiter, then a match-only-once rule applies, -described in C<m?PATTERN?> below. If "'" (single quote) is the delimiter, +described in C<m?PATTERN?> below. If "'" (single quote) is the delimiter, no interpolation is performed on the PATTERN. When using a character valid in an identifier, whitespace is required after the C<m>. @@ -1787,9 +1790,9 @@ The bottom line is that using C</o> is almost never a good idea. =item The empty pattern // If the PATTERN evaluates to the empty string, the last -I<successfully> matched regular expression is used instead. In this +I<successfully> matched regular expression is used instead. In this case, only the C<g> and C<c> flags on the empty pattern are honored; -the other flags are taken from the original pattern. If no match has +the other flags are taken from the original pattern. If no match has previously succeeded, this will (silently) act instead as a genuine empty pattern (which will always match). @@ -1836,29 +1839,29 @@ $Etc. The conditional is true if any variables were assigned; that is, if the pattern matched. The C</g> modifier specifies global pattern matching--that is, -matching as many times as possible within the string. How it behaves -depends on the context. In list context, it returns a list of the +matching as many times as possible within the string. How it behaves +depends on the context. In list context, it returns a list of the substrings matched by any capturing parentheses in the regular -expression. If there are no parentheses, it returns a list of all +expression. If there are no parentheses, it returns a list of all the matched strings, as if there were parentheses around the whole pattern. In scalar context, each execution of C<m//g> finds the next match, returning true if it matches, and false if there is no further match. The position after the last match can be read or set using the C<pos()> -function; see L<perlfunc/pos>. A failed match normally resets the +function; see L<perlfunc/pos>. A failed match normally resets the search position to the beginning of the string, but you can avoid that -by adding the C</c> modifier (for example, C<m//gc>). Modifying the target +by adding the C</c> modifier (for example, C<m//gc>). Modifying the target string also resets the search position. =item \G assertion You can intermix C<m//g> matches with C<m/\G.../g>, where C<\G> is a zero-width assertion that matches the exact position where the -previous C<m//g>, if any, left off. Without the C</g> modifier, the +previous C<m//g>, if any, left off. Without the C</g> modifier, the C<\G> assertion still anchors at C<pos()> as it was at the start of the operation (see L<perlfunc/pos>), but the match is of course only -attempted once. Using C<\G> without C</g> on a target string that has +attempted once. Using C<\G> without C</g> on a target string that has not previously had a C</g> match applied to it is the same as using the C<\A> assertion to match the beginning of the string. Note also that, currently, C<\G> is only properly supported when anchored at the @@ -1929,8 +1932,8 @@ The last example should print: Final: 'q', pos=8 Notice that the final match matched C<q> instead of C<p>, which a match -without the C<\G> anchor would have done. Also note that the final match -did not update C<pos>. C<pos> is only updated on a C</g> match. If the +without the C<\G> anchor would have done. Also note that the final match +did not update C<pos>. C<pos> is only updated on a C</g> match. If the final match did indeed match C<p>, it's a good bet that you're running a very old (pre-5.6.0) version of Perl. @@ -2047,7 +2050,7 @@ its own pair of quotes, which may or may not be bracketing quotes, for example, C<s(foo)(bar)> or C<< s<foo>/bar/ >>. A C</e> will cause the replacement portion to be treated as a full-fledged Perl expression and evaluated right then and there. It is, however, syntax checked at -compile-time. A second C<e> modifier will cause the replacement portion +compile-time. A second C<e> modifier will cause the replacement portion to be C<eval>ed before being run as a Perl expression. Examples: @@ -2338,7 +2341,7 @@ is complemented. If the C</d> modifier is specified, any characters specified by SEARCHLIST not found in REPLACEMENTLIST are deleted. (Note that this is slightly more flexible than the behavior of some B<tr> programs, which delete anything they find in the SEARCHLIST, -period.) If the C</s> modifier is specified, sequences of characters +period.) If the C</s> modifier is specified, sequences of characters that were transliterated to the same character are squashed down to a single instance of the character. @@ -2430,7 +2433,7 @@ the same rules as normal double quoted strings. =item Single Quotes Single quotes indicate the text is to be treated literally with no -interpolation of its content. This is similar to single quoted +interpolation of its content. This is similar to single quoted strings except that backslashes have no special meaning, with C<\\> being treated as two backslashes and not one as they would in every other quoting construct. @@ -2453,7 +2456,7 @@ can and do make good use of. =item Backticks The content of the here doc is treated just as it would be if the -string were embedded in backticks. Thus the content is interpolated +string were embedded in backticks. Thus the content is interpolated as though it were double quoted and then executed via the shell, with the results of the execution returned. @@ -2523,7 +2526,7 @@ you would have to write outside of string evals. Additionally, quoting rules for the end-of-string identifier are -unrelated to Perl's quoting rules. C<q()>, C<qq()>, and the like are not +unrelated to Perl's quoting rules. C<q()>, C<qq()>, and the like are not supported in place of C<''> and C<"">, and the only interpolation is for backslashing the quoting character: @@ -2571,18 +2574,18 @@ one to four, but these passes are always performed in the same order. The first pass is finding the end of the quoted construct, where the information about the delimiters is used in parsing. During this search, text between the starting and ending delimiters -is copied to a safe location. The text copied gets delimiter-independent. +is copied to a safe location. The text copied gets delimiter-independent. If the construct is a here-doc, the ending delimiter is a line -that has a terminating string as the content. Therefore C<<<EOF> is +that has a terminating string as the content. Therefore C<<<EOF> is terminated by C<EOF> immediately followed by C<"\n"> and starting from the first column of the terminating line. When searching for the terminating line of a here-doc, nothing -is skipped. In other words, lines after the here-doc syntax +is skipped. In other words, lines after the here-doc syntax are compared with the terminating string line by line. For the constructs except here-docs, single characters are used as starting -and ending delimiters. If the starting delimiter is an opening punctuation +and ending delimiters. If the starting delimiter is an opening punctuation (that is C<(>, C<[>, C<{>, or C<< < >>), the ending delimiter is the corresponding closing punctuation (that is C<)>, C<]>, C<}>, or C<< > >>). If the starting delimiter is an unpaired character like C</> or a closing @@ -2633,7 +2636,7 @@ the example above is not C<m//x>, but rather C<m//> with no C</x> modifier. So the embedded C<#> is interpreted as a literal C<#>. Also no attention is paid to C<\c\> (multichar control char syntax) during -this search. Thus the second C<\> in C<qq/\c\/> is interpreted as a part +this search. Thus the second C<\> in C<qq/\c\/> is interpreted as a part of C<\/>, and the following C</> is not recognized as a delimiter. Instead, use C<\034> or C<\x1c> at the end of quoted constructs. @@ -2962,7 +2965,7 @@ is equivalent to the following Perl-like pseudo code: except that it isn't so cumbersome to say, and will actually work. It really does shift the @ARGV array and put the current filename into the $ARGV variable. It also uses filehandle I<ARGV> -internally. <> is just a synonym for <ARGV>, which +internally. <> is just a synonym for <ARGV>, which is magical. (The pseudo code above doesn't work because it treats <ARGV> as non-magical.) @@ -3232,7 +3235,7 @@ X<number, arbitrary precision> The standard C<Math::BigInt>, C<Math::BigRat>, and C<Math::BigFloat> modules, along with the C<bignum>, C<bigint>, and C<bigrat> pragmas, provide variable-precision arithmetic and overloaded operators, although -they're currently pretty slow. At the cost of some space and +they're currently pretty slow. At the cost of some space and considerable speed, they avoid the normal pitfalls associated with limited-precision representations. @@ -3254,7 +3257,8 @@ Or with rationals: a*b is 1/11 Several modules let you calculate with (bound only by memory and CPU time) -unlimited or fixed precision. There are also some non-standard modules that +unlimited or fixed precision. There +are also some non-standard modules that provide faster implementations via external C libraries. Here is a short, but incomplete summary: -- Perl5 Master Repository
