- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

7.7 Binding Operators

Binary "=~" binds a scalar expression to a pattern match. Certain operations search or modify the string $_ by default. This operator makes that kind 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 $_. When used in scalar context, the return value generally indicates the success of the operation. Behavior in list context depends on the particular operator. See 7.30 for details and "Perl regular expressions tutorial" (perlretut) in Perl Tutorials for examples using these operators.

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. Note that this means that its contents will be interpolated twice, so

'\\' =~ q'\\';

is not ok, as the regex engine will end up trying to compile the pattern \, which it will consider a syntax error.

Binary "!~" is just like "=~" except the return value is negated in the logical sense.

ISBN 9781906966027Perl Language Reference ManualSee the print edition