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

Re: Replacing matches within string without splitting.

by johngg (Abbot)
on Jan 02, 2013 at 09:56 UTC ( #1011242=note: print w/ replies, xml ) Need Help??


in reply to Replacing matches within string without splitting.

A variation on the sprintf solutions using split, map and join.

$ perl -E ' > say join q{,}, map { sprintf q{%02d}, $_ } split m{,} for qw{ > 1,2,3,4 > 8,9,10,11 > 7,8,9,10 > 12,13,14,15 > };' 01,02,03,04 08,09,10,11 07,08,09,10 12,13,14,15

I hope this is of interest.

Cheers,

JohnGG


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (19)
As of 2015-07-02 19:46 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 (45 votes), past polls