Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Replacing a string with a memory variable

by VSarkiss (Monsignor)
on Jun 28, 2006 at 14:08 UTC ( #558021=note: print w/replies, xml ) Need Help??


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:

my $fmt = '<section id="ch%02dfm" label="" xreflabel="" role="fm">'; # ..later.. $_ =~ s/<CT>/sprintf $fmt, $acno/ge;
I guessed at the %02d in the format string based on your sample.

BTW, the default target for the substitution is $_ so you could actually shorten the assignment to just

s/<CT>/sprintf $fmt, $acno/ge;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://558021]
help
Chatterbox?
[marto]: it makes things less stressful for the parents that's for sure :P
[Corion]: Yeah (although their mother was somewhat stressed out regardless) - but it made for an otherwise relaxed evening ;)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2016-12-08 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (139 votes). Check out past polls.