in reply to Re^2: Progressive matching w/substitutions
in thread Progressive matching w/substitutions

Neither of those produces the desired output for me. $x is never incremented. Since you require a space at the end of the string-to-be-substituted, there is no substitution after the last abc, and the desired spacing in the output is wrong:

Those problems were present in the OP's posted code. They weren't problems with the post to which you replied. Presumably, the OP's code is different than what he posted, since the output he gave doesn't match the code he posted. Since the OP will have to retrofit the solution anyway, these details aren't important. That's why I took a few small liberties in my own solution.

  • Comment on Re^3: Progressive matching w/substitutions

Replies are listed 'Best First'.
Re^4: Progressive matching w/substitutions
by broomduster (Priest) on Aug 09, 2008 at 10:50 UTC
    You are correct that there were problems in the OP's code. Since the OP also showed desired output, I was expecting that posted solutions would actually produce that output. Yours and dreadpiratepeter's solutions produced the desired output, but Jstrom's did not.

    Or perhaps I misunderstand.

      You are correct that there were problems in the OP's code. Since the OP also showed desired output, I was expecting that posted solutions would actually produce that output.
      FWIW, my post originally said that I had multiple incantations of the code, none of which worked, and that the one posted was an arbitrary one from that set. I didn't necessarily want to focus on the code, per se, but the more fundamental underlying question: why doesn't progressive matching work with s/// expressions as it does with m//? My code was drawing attention to the byproduct of this lack of support for s/// was the need for too much complexity in the while() loop, which also produced code that (in my case, in my examples) didn't work.

      I think I overcomplicated things by introducing too much stuff into the post.