No such thing as a small change | |
PerlMonks |
Some odd ambiguity in this regexby misterperl (Pilgrim) |
on Jun 05, 2020 at 15:10 UTC ( [id://11117718]=perlquestion: print w/replies, xml ) | Need Help?? |
misterperl has asked for the wisdom of the Perl Monks concerning the following question:
Perl 5.16, I'm trying to count digits in a scalar
..the expression inexpliquably drops the 1st digit (the 1) the first time I evaluate the regex:
But after that first time, the 1 is back? I changed nothing- just examined it again... I changed the dot and plus to non-interpolated chars like W and Z, and it finds all the digits consistently. So I'm thinking its some kind of interpolation thing BUT, why would it interpolate differently on trial 1, than on subsequent trials? And if it IS some interpolation thing, why remove the first digit when the interpolated chars are in the middle? Its perplexing! I also tried /{expression}/ and /\Qexpression\E/, and using $x instead of $_ - none worked. How can I turn off interpolation, assuming that's the issue? I suppose one *fix* is to simply do the same evaluation 2X, but I can't imagine that's what Larry would suggest! TYVM
Back to
Seekers of Perl Wisdom
|
|