Variables may be used in Regular expressions and are interpolated as in usual double quoted strings. Use \$ to represent a real dollar except at end of string when it safely represents end of string anchor. |
In match /regexp/i , the i instructs one to ignore case in match |
In substitution s/regexp1/regexp2/g, the g instructs substitution to occur at all possible places in string -- normally only the first match in a string is found |
i and g can be used together |
$line =~ s/regexp1/regexp2/ ; # Illustrates how we use substitution s on general variable |
As with m, s can use any delimiter and so |
$line =~ s#regexp1#regexp2# ; # is equivalent form |