in reply to Regex, Function and Default variables
In particular, when $str =~ m//g is used in scalar context (as in your posted examples), it requests match position pos($str) to be remembered; further m//g continue from there. (But assigning to $str will forget the pos!)
# m// in list context, no g flag if (my @match = $str =~ m/(pattern1)(pattern2)/i) { $str = function($match[0]); $var1 = function($match[1]); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex, Function and Default variables
by tosaiju (Acolyte) on Nov 21, 2013 at 09:00 UTC |