[lug] perl question

Stephen Queen svq at peakpeak.com
Sun Apr 28 13:39:40 MDT 2002

j davis wrote:

> what does the gm do after the " #/ " ?
> thanks
> jd

In the regular expression $array=~s/^/#/gm; the "=~" is called the binding operator and matches the string on the
left with the pattern on the right. The "s "is the substitution operator, the "^" is an anchor that denotes the
beginning of the string. The "#" is what is going to be substituted, the g is the global operator, meaning for the
entire string, and the m is the multiple line operator, meaning that if there is more than one line do the same for
each line. So this expression means for the string represented by the variable $array substitute the beginning of
the string with the # and do it for every line in the string.

Steve Queen

More information about the LUG mailing list