Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011242]
[marto]: good morning all, TCIF
[Corion]: Hi marto! Indeed, Crunchy be thanked!
choroba had a Christams party at work yesterday. Slow morning today...
[Corion]: I guess I should not read some discussions on HackerNews - the crowd there is weirdly different - "you have to stay current in tech" (by following all the latest JS trends) is a meme there, but it doesn't really match my experience
[Corion]: At least in my area, experience can beat most new tech anyway because most new tech is just a rehash of things abandoned in the 70s and we still have a lot of that ;)
[Corion]: choroba: Ah, that will be next Friday for $work ;) Drinking enough water is key ;))

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2016-12-09 10:15 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (150 votes). Check out past polls.