X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlop.pod;h=7b0b0d2294ab1a26040dc871ba025da2be1d009f;hb=8d159ec130d0a3a6340d8398c9db207a5efafc87;hp=3a8de2aef198e66b8f2100367dca9a34175e34aa;hpb=63acfd0033368edc5dd21a89732267e5921511f1;p=p5sagit%2Fp5-mst-13.2.git
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 3a8de2a..7b0b0d2 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -53,7 +53,7 @@ values only, not array values.
nonassoc list operators (rightward)
right not
left and
- left or xor err
+ left or xor
In the following sections, these operators are covered in precedence order.
@@ -200,7 +200,7 @@ concatenated with the identifier is returned. Otherwise, if the string
starts 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 (exluding "+" or "-"), Perl will attempt to convert
+non-alphabetic character (excluding "+" or "-"), Perl will attempt to convert
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.
@@ -260,19 +260,29 @@ X<*>
Binary "/" divides two numbers.
X> X
-Binary "%" computes the modulus of two numbers. Given integer
+Binary "%" is the modulo operator, which computes the division
+remainder of its first argument with respect to its second argument.
+Given integer
operands C<$a> and C<$b>: If C<$b> is positive, then C<$a % $b> is
-C<$a> minus the largest multiple of C<$b> that is not greater than
+C<$a> minus the largest multiple of C<$b> less than or equal to
C<$a>. If C<$b> is negative, then C<$a % $b> is C<$a> minus the
smallest multiple of C<$b> that is not less than C<$a> (i.e. the
result will be less than or equal to zero). If the operands
-C<$a> and C<$b> are floting point values, only the integer portion
-of C<$a> and C<$b> will be used in the operation.
+C<$a> and C<$b> are floating point values and the absolute value of
+C<$b> (that is C) is less than C<(UV_MAX + 1)>, only
+the integer portion of C<$a> and C<$b> will be used in the operation
+(Note: here C means the maximum of the unsigned integer type).
+If the absolute value of the right operand (C) is greater than
+or equal to C<(UV_MAX + 1)>, "%" computes the floating-point remainder
+C<$r> in the equation C<($r = $a - $i*$b)> where C<$i> is a certain
+integer that makes C<$r> have the same sign as the right operand
+C<$b> (B as the left operand C<$a> like C function C)
+and the absolute value less than that of C<$b>.
Note that when C
-This is just like the C search, except that it matches only
-once between calls to the reset() operator. This is a useful
-optimization when you want to see only the first occurrence of
-something in each file of a set of files, for instance. Only C?>
-patterns local to the current package are reset.
+This operator quotes (and possibly compiles) its I as a regular
+expression. I is interpolated the same way as I
+in C. If "'" is used as the delimiter, no interpolation
+is done. Returns a Perl value which may be used instead of the
+corresponding C expression. The returned value is a
+normalized version of the original pattern. It magically differs from
+a string containing the same characters: C[ returns "Regexp",
+even though dereferencing the result returns undef.
- while (<>) {
- if (?^$?) {
- # blank line between header and body
- }
- } continue {
- reset if eof; # clear ?? status for next file
+For example,
+
+ $rex = qr/my.STRING/is;
+ print $rex; # prints (?si-xm:my.STRING)
+ s/$rex/foo/;
+
+is equivalent to
+
+ s/my.STRING/foo/is;
+
+The result may be used as a subpattern in a match:
+
+ $re = qr/$pattern/;
+ $string =~ /foo${re}bar/; # can be interpolated in other patterns
+ $string =~ $re; # or used standalone
+ $string =~ /$re/; # or this way
+
+Since Perl may compile the pattern at the moment of execution of qr()
+operator, using qr() may have speed advantages in some situations,
+notably if the result of qr() is used standalone:
+
+ sub match {
+ my $patterns = shift;
+ my @compiled = map qr/$_/i, @$patterns;
+ grep {
+ my $success = 0;
+ foreach my $pat (@compiled) {
+ $success = 1, last if /$pat/;
+ }
+ $success;
+ } @_;
}
-This usage is vaguely deprecated, which means it just might possibly
-be removed in some distant future version of Perl, perhaps somewhere
-around the year 2168.
+Precompilation of the pattern into an internal representation at
+the moment of qr() avoids a need to recompile the pattern every
+time a match C$pat/> is attempted. (Perl has many other internal
+optimizations, but none would be triggered in the above example if
+we did not use qr() operator.)
-=item m/PATTERN/cgimosx
+Options are:
+
+ m Treat string as multiple lines.
+ s Treat string as single line. (Make . match a newline)
+ i Do case-insensitive pattern matching.
+ x Use extended regular expressions.
+ p When matching preserve a copy of the matched string so
+ that ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be defined.
+ o Compile pattern only once.
+
+If a precompiled pattern is embedded in a larger pattern then the effect
+of 'msixp' will be propagated appropriately. The effect of the 'o'
+modifier has is not propagated, being restricted to those patterns
+explicitly using it.
+
+See L for additional information on valid syntax for STRING, and
+for a detailed look at the semantics of regular expressions.
+
+=item m/PATTERN/msixpogc
X X
X X X X
-X X X X X X
+X X X X X X X X
-=item /PATTERN/cgimosx
+=item /PATTERN/msixpogc
Searches a string for a pattern match, and in scalar context returns
true if it succeeds, false if it fails. If no string is specified
@@ -1070,15 +1160,11 @@ rather tightly.) See also L. See L for
discussion of additional considerations that apply when C]