Output:#!/usr/bin/perl use strict; use warnings; local $/; local $_ = <DATA>; my $c; s/(<xxx>)(?{++$c;})/<$c>$1/g; print; __DATA__ <xxx>fo</xxx> <p>ba</p> <xxx>foo</xxx><xxx>bar</xxx> <p>foobar</p>
<1><xxx>fo</xxx> <p>ba</p> <2><xxx>foo</xxx><3><xxx>bar</xxx> <p>foobar</p>
In reply to Re: find and replace counter
by poolpi
in thread find and replace counter
by texuser74
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |