As a scalar operator:
if (101 .. 200) { print; } # print 2nd hundred lines, short for
- # if ($. == 101 .. $. == 200) ...
+ # if ($. == 101 .. $. == 200) { print; }
next LINE if (1 .. /^$/); # skip header lines, short for
- # ... if ($. == 1 .. /^$/);
+ # next LINE if ($. == 1 .. /^$/);
# (typically in a loop labeled LINE)
s/^/> / if (/^$/ .. eof()); # quote body
$in_header = 1 .. /^$/;
$in_body = /^$/ .. eof;
if ($in_header) {
- # ...
+ # do something
} else { # in body
- # ...
+ # do something else
}
} continue {
close ARGV if eof; # reset $. each file
%hash = ( $key => $value );
login( $username => $password );
-=head2 Yada Yada Operators
-X<...> X<... operator> X<!!!> X<!!! operator> X<???> X<??? operator>
-X<yada yada operator>
+=head2 Yada Yada 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
+The yada yada operator (noted C<...>) is a placeholder for code.
+It parses without error, but when executed it throws an exception
with the text C<Unimplemented>:
sub 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?
+It takes no argument.
=head2 List Operators (Rightward)
X<operator, list, rightward> X<list operator>
c Do not reset search position on a failed match when /g is in effect.
If "/" is the delimiter then the initial C<m> is optional. With the C<m>
-you can use any pair of non-alphanumeric, non-whitespace characters
+you can use any pair of non-whitespace characters
as delimiters. This is particularly useful for matching path names
that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is
the delimiter, then the match-only-once rule of C<?PATTERN?> applies.
If "'" 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>.
PATTERN may contain variables, which will be interpolated (and the
pattern recompiled) every time the pattern search is evaluated, except
regexp tries to match where the previous one leaves off.
$_ = <<'EOL';
- $url = URI::URL->new( "http://www/" ); die if $url eq "xXx";
+ $url = URI::URL->new( "http://example.com/" ); die if $url eq "xXx";
EOL
LOOP:
{
e Evaluate the right side as an expression.
ee Evaluate the right side as a string then eval the result
-Any non-alphanumeric, non-whitespace delimiter may replace the
-slashes. If single quotes are used, no interpretation is done on the
-replacement string (the C</e> modifier overrides this, however). Unlike
-Perl 4, Perl 5 treats backticks as normal delimiters; the replacement
-text is not evaluated as a command. If the
-PATTERN is delimited by bracketing quotes, the REPLACEMENT has its own
-pair of quotes, which may or may not be bracketing quotes, e.g.,
+Any non-whitespace delimiter may replace the slashes. Add space after
+the C<s> when using a character allowed in identifiers. If single quotes
+are used, no interpretation is done on the replacement string (the C</e>
+modifier overrides this, however). Unlike Perl 4, Perl 5 treats backticks
+as normal delimiters; the replacement text is not evaluated as a command.
+If the PATTERN is delimited by bracketing quotes, the REPLACEMENT has
+its own pair of quotes, which may or may not be bracketing quotes, e.g.,
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
while (($_ = <STDIN>) ne '0') { ... }
while (<STDIN>) { last unless $_; ... }
-In other boolean contexts, C<< <I<filehandle>> >> without an
-explicit C<defined> test or comparison elicit a warning if the
+In other boolean contexts, C<< <filehandle> >> without an
+explicit C<defined> test or comparison elicits a warning if the
C<use warnings> pragma or the B<-w>
command-line switch (the C<$^W> variable) is in effect.