As I understand it, /g is not a substitute for /sm
print is not a substitute for system. True, but obvious.
In fact, not only are they not equivalent, s, m and g are orthgonal.
s affects what . matches.
m affects what ^ and $ matches.
g affects the number of substitutions that will be made.
/g is sort of an iterator that lets you steadily step the matches in a string
No. You're thinking of m//g in void and scalar context. That's neither the case for m//g in list context nor for s///g.
my $x1 = $1 if $test =~ s/A/AA/g;
Off-topic, but my $var if ... is wrong. my has a run-time effect, so it shouldn't be executed conditionally.
In reply to Re^2: Bug or feature? s/// and the g option
by ikegami
in thread Bug or feature? s/// and the g option
by Belgarion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |