http://qs321.pair.com?node_id=180548

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?

Thanks,
cidaris