- or download this
$a =~ $b
- or download this
$a =~ m/$b/;
- or download this
$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.
- or download this
$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.
- or download this
$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.
- or download this
$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.
- or download this
my $pat = 'a';
...
$str =~ m/$pat/ # No need to compile in advance.
$str =~ /$pat/ # Same
$str =~ $pat # Same
- or download this
my $pat = 'a';
my $repl = 'b';
...
$str =~ s/$re/$repl/ # Performs a substitution.
$str =~ s/$pat/$repl/ # No need to compile in advance.