$a =~ $b #### $a =~ m/$b/; #### $p = '4+5*6'; $str =~ m/$p/; # Doesn't perform arithmetic. $p = 'm/a/'; $str =~ m/$p/; # Doesn't search for `a`. $p = 's/a/b/'; $str =~ m/$p/; # Doesn't perform a substitution. #### $p = '4+5*6'; $str =~ $p; # Doesn't perform arithmetic. $p = 'm/a/'; $str =~ $p; # Doesn't search for `a`. $p = 's/a/b/'; $str =~ $p; # Doesn't perform a substitution. #### $p = '4+5*6'; $re = qr/$p/; $str =~ m/$re/; # Still doesn't. $p = 'm/a/'; $re = qr/$p/; $str =~ m/$re/; # Still doesn't. $p = 's/a/b/'; $re = qr/$p/; $str =~ m/$re/; # Still doesn't. #### $p = '4+5*6'; $re = qr/$p/; $str =~ $re; # Still doesn't. $p = 'm/a/'; $re = qr/$p/; $str =~ $re; # Still doesn't. $p = 's/a/b/'; $re = qr/$p/; $str =~ $re; # Still doesn't. #### my $pat = 'a'; my $re = qr/$pat/; $str =~ m/$re/ # Performs a match. $str =~ /$re/ # Same $str =~ $re # Same $str =~ m/$pat/ # No need to compile in advance. $str =~ /$pat/ # Same $str =~ $pat # Same #### my $pat = 'a'; my $repl = 'b'; my $re = qr/$pat/; $str =~ s/$re/$repl/ # Performs a substitution. $str =~ s/$pat/$repl/ # No need to compile in advance.