in reply to On patterns and more

the =~ operator is part of a regular expression. One of the most powerful features I know. Check perlre, perlreref, perlrebackslash, perlrecharclass, perlreref, perlrequick or perlretut.

Replies are listed 'Best First'.
Re^2: On patterns and more
by ikegami (Patriarch) on Mar 07, 2011 at 04:35 UTC

    Not at all. It relates to the match, substitution and tr operators, not regular expressions. Some of those operators take a regular expression for argument, but that's unrelated to «=~».


    «=~» is the means by which one specifies the operand (argument) for some operators.

    $x =~ m/.../ # Matches against $x $x =~ s/.../.../ # Modifies $x $x =~ tr/.../.../ # Modifies $x

    «/.../» is short for «m/.../».

    Operators that support «=~» default to using «$_» if «=~» isn't' used. For example, «/.../» is short for «$_ =~ /.../».

    The match operator is implied if the RHS of «=~» is an expression, so «$x =~ "pat"» means «$x =~ /pat/» and «$x =~ $pat» means «$x =~ /$pat/».