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
-pattern must be compiled every time the expression is evaluated).
+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
the logical sense.
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
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: