Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: In place replace, ignoring between quotes

by LanX (Saint)
on Oct 25, 2013 at 18:42 UTC ( [id://1059732]=note: print w/replies, xml ) Need Help??


in reply to In place replace, ignoring between quotes

last but not least

DB<171> $str=$str0 => " bla0 \"ignore a1\" bla1 \"ignore a2\" bla2" DB<172> @parts=split '"',$str => (" bla0 ", "ignore a1", " bla1 ", "ignore a2", " bla2") DB<173> map {s/a/A/ unless $x++%2} @parts => (1, 1, 1, 1, 1) DB<174> $str=join '"',@parts => " blA0 \"ignore a1\" blA1 \"ignore a2\" blA2"

also as one-liner

DB<185> $x=0;$str=$str0 => " bla0 \"ignore a1\" bla1 \"ignore a2\" bla2" DB<186> $str= join '"', map {s/a/A/ unless $x++%2;$_} split '"', $st +r => " blA0 \"ignore a1\" blA1 \"ignore a2\" blA2"

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found