in reply to Replacing a string with a memory variable
Another WTDI would be to use sprintf, if only to make the code more readable:
I guessed at the %02d in the format string based on your sample.my $fmt = '<section id="ch%02dfm" label="" xreflabel="" role="fm">'; # ..later.. $_ =~ s/<CT>/sprintf $fmt, $acno/ge;
BTW, the default target for the substitution is $_ so you could actually shorten the assignment to just
s/<CT>/sprintf $fmt, $acno/ge;
In Section
Seekers of Perl Wisdom