In this example, the $foo variable contains a value of bar.
my $foo = "bar";
The =~ operator is used to replace a value in a variable. In this example, bar is replaced with Hello World. The $foo variable will now contain a value of "Hello World". You can use either forward slash or pipe.
$foo =~ s/bar/Hello World/g; $foo =~ s|bar|Hello World|g;
( and ) characters
The ( and ) characters will need to be escaped. For example, let's say you want to replace (foo) with (bar).
$foo =~ s|\(foo\)|\(bar\)|g;