How can I replace "old" with "new" in $a?
$a = "this is old";
$a =~ s/old/new/;
print $a;
Output> this is new
How can I check if $a includes "test"?
$a = "this is a test";
print $a =~ /test/ ? "includes" : "doesn't include";
Output> includes
How can I check if $a does not include "test"?
$a = "this is a teeeeest";
print $a !~ m|test| ? "does not include" : "includes";
Output> does not include
How can I write arbitrary quotes to a string?
$a = qq{"this is 'a string' that has 'many quotes'". Ok?};
print $a;
Output > "this is 'a string' that has 'many quotes'". Ok?
How can I escape characters in a string?
$a = "\\b @ c is (d)"; # " ", "@", "(", ")" will be escaped
$a = quotemeta $a;
print $a;
Output > \\b\ \@\ c\ is\ \(d\)