Problems? Is your data what you think it is? | |
PerlMonks |
Can you assign to pos() in a s/foo/bar/gby johngg (Canon) |
on Oct 25, 2007 at 11:01 UTC ( [id://647133]=perlquestion: print w/replies, xml ) | Need Help?? |
johngg has asked for the wisdom of the Perl Monks concerning the following question:
There were several suggested methods in answer to this thread. My solution repeatedly substituted in a while loop. I got to wondering if you could do a global substitution in one fell swoop instead by assigning to pos in a regex code block to set the match back to the start of the string. This doesn't seem to work although the assignment to pos() does seem to register. Here's a short script to show what I'm trying, firstly the loop variant then the global substitution.
Here's the output
As you can see, it doesn't look as if matching is reset so only one substitution is done. Am I trying to do something impossible here? Cheers, JohnGG
Back to
Seekers of Perl Wisdom
|
|