Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Replacing matches within string without splitting.

by Anonymous Monk
on Jan 02, 2013 at 08:29 UTC ( #1011228=note: print w/ replies, xml ) Need Help??


in reply to Replacing matches within string without splitting.

The /e switch coupled with sprintf?

while (<DATA>) { s/(\d+)/ sprintf("%02d", $1) /ge; print $_; } __DATA__ 1,2,3,4 8,9,10,11 7,8,9,10 12,13,14,15


Comment on Re: Replacing matches within string without splitting.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2015-07-08 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls