1 | 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. |
2 | In match /regexp/i , the i instructs one to ignore case in match |
3 | 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 |
4 | i and g can be used together |
5 | $line =~ s/regexp1/regexp2/ ; # Illustrates how we use substitution s on general variable |
6 | As with m, s can use any delimiter and so |
7 | $line =~ s#regexp1#regexp2# ; # is equivalent form |