of operation work on some other string. The right argument is a search
pattern, substitution, or transliteration. The left argument is what is
supposed to be searched, substituted, or transliterated instead of the default
-$_. The return value indicates the success of the operation. (If the
+$_. The return value indicates the success of the operation. 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. This can be is less efficient than an explicit search, because the
+time. This can be less efficient than an explicit search, because the
pattern must be compiled every time the expression is evaluated.
Binary "!~" is just like "=~" except the return value is negated in
operator is not as well defined for negative operands, but it will
execute faster.
-Binary "x" is the repetition operator. In scalar context, it
-returns a string consisting of the left operand repeated the number of
-times specified by the right operand. In list context, if the left
-operand is a list in parentheses, it repeats the list.
+Binary "x" is the repetition operator. In scalar context or if the left
+operand is not enclosed in parentheses, it returns a string consisting
+of the left operand repeated the number of times specified by the right
+operand. In list context, if the left operand is enclosed in
+parentheses, it repeats the list.
print '-' x 80; # print row of dashes
unlink("alpha", "beta", "gamma")
|| (gripe(), next LINE);
-Use "or" for assignment is unlikely to do what you want; see below.
+Using "or" for assignment is unlikely to do what you want; see below.
=head2 Range Operators
Although these are grouped by family, they all have the precedence
of assignment.
-Unlike in C, the assignment operator produces a valid lvalue. Modifying
-an assignment is equivalent to doing the assignment and then modifying
-the variable that was assigned to. This is useful for modifying
-a copy of something, like this:
+Unlike in C, the scalar assignment operator produces a valid lvalue.
+Modifying an assignment is equivalent to doing the assignment and
+then modifying the variable that was assigned to. This is useful
+for modifying a copy of something, like this:
($tmp = $global) =~ tr [A-Z] [a-z];
$a += 2;
$a *= 3;
+Similarly, a list assignment in list context produces the list of
+lvalues assigned to, and a list assignment in scalar context returns
+the number of elements produced by the expression on the right hand
+side of the assignment.
+
=head2 Comma Operator
Binary "," is the comma operator. In scalar context it evaluates
\x1b hex char (ESC)
\x{263a} wide hex char (SMILEY)
\c[ control char (ESC)
+ \N{name} named char
\l lowercase next char
\u uppercase next char
\Q quote non-word characters till \E
If C<use locale> is in effect, the case map used by C<\l>, C<\L>, C<\u>
-and C<\U> is taken from the current locale. See L<perllocale>.
+and C<\U> is taken from the current locale. See L<perllocale>. For
+documentation of C<\N{name}>, see L<charnames>.
All systems use the virtual C<"\n"> to represent a line terminator,
called a "newline". There is no such thing as an unvarying, physical
my @compiled = map qr/$_/i, @$patterns;
grep {
my $success = 0;
- foreach my $pat @compiled {
+ foreach my $pat (@compiled) {
$success = 1, last if /$pat/;
}
$success;
qw(foo bar baz)
-is exactly equivalent to the list:
+is semantically equivalent to the list:
- ('foo', 'bar', 'baz')
+ 'foo', 'bar', 'baz'
Some frequently seen examples:
See L<perlfunc/vec> for information on how to manipulate individual bits
in a bit vector.
+=head2 Version tuples
+
+A version number of the form C<v1.2.3.4> is parsed as a dual-valued literal.
+It has the string value of C<"\x{1}\x{2}\x{3}\x{4}"> (i.e., a utf8 string)
+and a numeric value of C<1 + 2/1000 + 3/1000000 + 4/1000000000>. This is
+useful for representing and comparing version numbers.
+
+Version tuples are accepted by both C<require> and C<use>. The C<$^V> variable
+contains the running Perl interpreter's version in this format.
+See L<perlvar/$^V>.
+
=head2 Integer Arithmetic
By default, Perl assumes that it must do most of its arithmetic in
The non-standard modules SSLeay::BN and Math::Pari provide
equivalent functionality (and much more) with a substantial
performance savings.
+
+=cut