Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: replace a character based on rule file

by kcott (Chancellor)
on Dec 04, 2012 at 08:17 UTC ( #1007029=note: print w/replies, xml ) Need Help??


in reply to replace a character based on rule file

G'day lakssreedhar,

You haven't actually asked a question - please take a look at: How do I post a question effectively?

For the scenario you describe, I'd be looking at a positive look-behind assertion - see perlre - Extended Patterns for details.

Here's an example:

$ perl -Mstrict -Mwarnings -E ' my @words = qw{door name dad naming}; for (@words) { s{(?<=na)m}{+d}; say; } ' door na+de dad na+ding

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007029]
help
Chatterbox?
[karlgoethebier]: funny that they call it Big Dipper in the US. Here this part of Ursa Major is called "Großer Wagen" Big wagon...or car as you like ;-)
[stonecolddevin]: morning all
[shmem]: Big Dipper
[karlgoethebier]: shmem: i remember this album. nice

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-11-21 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (308 votes). Check out past polls.

    Notices?