rray. The output from this example is
Matched on yon, Yon, son, con.
Once you get the hang of pattern matching, substitutions are quite straightforward and very powerful. The substitution operator is s/// that resembles the match operator but has three rather than two slashes. As with the match operator, any other character may be substituted for forward slashes, and the optional i, g, and o switches may be used.
The pattern to be replaced goes between the first and second delimiters, and the replacement pattern goes between the second and third. To take a simple example,
$house = "henhouse";
$house =~ s/hen/dog/;
change $house from henhouse to doghouse. Note that it isn't possible to use the =~ operation with a literal string in the way we did when matching; that's because you can't modify a literal constant. Instead, store the string in a variable and modify that.