Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Replacing matches within string without splitting.

by Athanasius (Chancellor)
on Jan 02, 2013 at 06:44 UTC ( #1011212=note: print w/replies, xml ) Need Help??

in reply to Replacing matches within string without splitting.

Another approach:

#! perl use Modern::Perl; while (<DATA>) { chomp; s{\b(\d)\b}{0$1}g; say; } __DATA__ 1,2,3,4 8,9,10,11 7,8,9,10 12,13,14,15


16:42 >perl 01,02,03,04 08,09,10,11 07,08,09,10 12,13,14,15 16:42 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Replacing matches within string without splitting.
by walkingthecow (Friar) on Jan 02, 2013 at 07:26 UTC
    That worked beautifully (in Perl 5.8 without Modern::Perl)! Thank you :)
    $channels =~ s{\b(\d)\b}{0$1}g;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011212]
[marioroy]: LA only $ and \ needed backslash, not ' and ".
[marioroy]: my @music_times = qx(find \$HOME/Music/ Albums -type f -iname '*.mp3' -exec mp3info -p "%S\\n" {} \\;);
[marioroy]: I wanted to come back and report on that.
[marioroy]: cheers

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-04-23 22:36 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (433 votes). Check out past polls.