Add diagnostics for "No such hook: %s".
[p5sagit/p5-mst-13.2.git] / pod / perlop.pod
index 355e8aa..f52f79f 100644 (file)
@@ -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<Argument "the string" isn't numeric in negation (-) at ...>.
@@ -260,9 +260,11 @@ X<*>
 Binary "/" divides two numbers.
 X</> X<slash>
 
-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
@@ -273,14 +275,14 @@ the integer portion of C<$a> and C<$b> will be used in the operation
 If the absolute value of the right operand (C<abs($b)>) 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> should have the same sign as the right operand
+integer that makes C<$r> have the same sign as the right operand
 C<$b> (B<not> as the left operand C<$a> like C function C<fmod()>)
 and the absolute value less than that of C<$b>.
 Note that when C<use integer> is in scope, "%" gives you direct access
-to the modulus operator as implemented by your C compiler.  This
+to the modulo operator as implemented by your C compiler.  This
 operator is not as well defined for negative operands, but it will
 execute faster.
-X<%> X<remainder> X<modulus> X<mod>
+X<%> X<remainder> X<modulo> X<mod>
 
 Binary "x" is the repetition operator.  In scalar context or if the left
 operand is not enclosed in parentheses, it returns a string consisting
@@ -447,8 +449,6 @@ X<cmp>
 
 Binary "~~" does a smart match between its arguments. Smart matching
 is described in L<perlsyn/"Smart matching in detail">.
-This operator is only available if you enable the "~~" feature:
-see L<feature> for more information.
 X<~~>
 
 "lt", "le", "ge", "gt" and "cmp" use the collation (sort) order specified
@@ -522,9 +522,9 @@ for selecting between two aggregates for assignment:
     @a = scalar(@b) || @c;     # really meant this
     @a = @b ? @b : @c;         # this works fine, though
 
-As more readable alternatives to C<&&>, C<//> and C<||> when used for
-control flow, Perl provides C<and>, C<err> and C<or> operators (see below).
-The short-circuit behavior is identical.  The precedence of "and", "err"
+As more readable alternatives to C<&&> and C<||> when used for
+control flow, Perl provides the C<and> and C<or> operators (see below).
+The short-circuit behavior is identical.  The precedence of "and"
 and "or" is much lower, however, so that you can safely use them after a
 list operator without the need for parentheses:
 
@@ -568,7 +568,7 @@ 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 till the next
+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.
 
@@ -809,6 +809,39 @@ between keys and values in hashes, and other paired elements in lists.
         %hash = ( $key => $value );
         login( $username => $password );
 
+=head2 Yada Yada Operators
+X<...> X<... operator> X<!!!> X<!!! operator> X<???> X<??? operator>
+X<yada yada operator>
+
+The yada yada operators are placeholders for code.  They parse without error,
+but when executed either throw an exception or a warning.
+
+The C<...> operator takes no arguments.  When executed, it throws an exception
+with the text C<Unimplemented>:
+
+    sub foo { ... }
+    foo();
+
+    Unimplemented at <file> line <line number>.
+
+The C<!!!> operator is similar, but it takes one argument, a string to use as
+the text of the exception:
+
+    sub bar { !!! "Don't call me, Ishmael!" }
+    bar();
+
+    Don't call me, Ishmael! at <file> line <line number>.
+
+The C<???> operator also takes one argument, but it emits a warning instead of
+throwing an exception:
+
+    sub baz { ??? "Who are you?  What do you want?" }
+    baz();
+    say "Why are you here?";
+
+    Who are you?  What do you want? at <file> line <line number>.
+    Why are you here?
+
 =head2 List Operators (Rightward)
 X<operator, list, rightward> X<list operator>
 
@@ -838,9 +871,9 @@ precedence.  This means that it short-circuits: i.e., the right
 expression is evaluated only if the left expression is true.
 
 =head2 Logical or, Defined or, and Exclusive Or
-X<operator, logical, or> X<operator, logical, xor> X<operator, logical, err>
+X<operator, logical, or> X<operator, logical, xor>
 X<operator, logical, defined or> X<operator, logical, exclusive or>
-X<or> X<xor> X<err>
+X<or> X<xor>
 
 Binary "or" returns the logical disjunction of the two surrounding
 expressions.  It's equivalent to || except for the very low precedence.
@@ -865,13 +898,6 @@ takes higher precedence.
 
 Then again, you could always use parentheses.
 
-Binary "err" is equivalent to C<//>--it's just like binary "or", except it
-tests its left argument's definedness instead of its truth.  There are two
-ways to remember "err":  either because many functions return C<undef> on
-an B<err>or, or as a sort of correction:  C<$a = ($b err 'default')>. This
-keyword is only available when the 'err' feature is enabled: see
-L<feature> for more information.
-
 Binary "xor" returns the exclusive-OR of the two surrounding expressions.
 It cannot short circuit, of course.
 
@@ -1158,6 +1184,8 @@ the life of the script.  However, mentioning C</o> constitutes a promise
 that you won't change the variables in the pattern.  If you change them,
 Perl won't even notice.  See also L<"qr/STRING/msixpo">.
 
+=item The empty pattern //
+
 If the PATTERN evaluates to the empty string, the last
 I<successfully> matched regular expression is used instead. In this
 case, only the C<g> and C<c> flags on the empty pattern is honoured -
@@ -1174,6 +1202,8 @@ will assume you meant defined-or.  If you meant the empty regex, just
 use parentheses or spaces to disambiguate, or even prefix the empty
 regex with an C<m> (so C<//> becomes C<m//>).
 
+=item Matching in list context
+
 If the C</g> option is not used, C<m//> in list context returns a
 list consisting of the subexpressions matched by the parentheses in the
 pattern, i.e., (C<$1>, C<$2>, C<$3>...).  (Note that here C<$1> etc. are
@@ -1220,6 +1250,8 @@ search position to the beginning of the string, but you can avoid that
 by adding the C</c> modifier (e.g. 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 C<\G> assertion
@@ -2214,6 +2246,18 @@ internally--<> is just a synonym for <ARGV>, which
 is magical.  (The pseudo code above doesn't work because it treats
 <ARGV> as non-magical.)
 
+Since the null filehandle uses the two argument form of L<perlfunc/open>
+it interprets special characters, so if you have a script like this:
+
+    while (<>) {
+        print;
+    }
+
+and call it with C<perl dangerous.pl 'rm -rfv *|'>, it actually opens a
+pipe, executes the C<rm> command and reads C<rm>'s output from that pipe.
+If you want all items in C<@ARGV> to be interpreted as file names, you
+can use the module C<ARGV::readonly> from CPAN.
+
 You can modify @ARGV before the first <> as long as the array ends up
 containing the list of filenames you really want.  Line numbers (C<$.>)
 continue as though the input were one big happy file.  See the example