in reply to sequential substitutions

#!/usr/bin/perl use strict; use warnings; my $fragment = ' <foo>3</foo> <foo>14</foo> <foo>159</foo> [...] '; print $fragment; my $n = 1; $fragment =~ s/\d+/ $n++ /ge; print $fragment;

Replies are listed 'Best First'.
Re^2: sequential substitutions
by Anonymous Monk on Aug 03, 2018 at 11:17 UTC

    This is pretty much what I was looking for (actually, it is even more than I was looking for - I thought I would at a minimum have to loop over the matches with a while statement :) ). I already have it incorporated into my program, and it is working.

    Thank you very much.