Sequential Replacementby cidaris (Friar)
|on Jul 09, 2002 at 17:27 UTC ( #180548=perlquestion: print w/replies, xml )||Need Help??|
cidaris has asked for the wisdom of the Perl Monks concerning the following question:
I currently have a big, ugly, repetitive, procedural way of doing this:
For every instance of ##REPLACE##, insert the next element of an array.
I was hoping there was some way I could use the \G and //g operators with an s//$rep/ where $rep=shift(@array) operation in order to make it work, but my attempts have failed with unexpected results (sometimes multiple ##REPLACE##(s) in the same line will get ignored, sometimes not.)
Has anyone tried doing something similar, or perhaps someone with much more REGEX experience has input?
Back to Seekers of Perl Wisdom