Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Syntactic Confectionery Delight
 
PerlMonks  

Re: Using Perl Regex to find & replace large chunks in code

by ikegami (Pope)
on Mar 11, 2013 at 19:01 UTC ( #1022848=note: print w/ replies, xml ) Need Help??


in reply to Using Perl Regex to find & replace large chunks in code

As a standalone script

local $/; my $search = <>; my $replace = <>; #local $^I = ''; # No backups. local $^I = '~'; # Make backups. while (<>) { s/\Q$search/$replace/g; print; }

Usage:

$ script.pl - - *.cstol search search search ^D replace replace replace ^D
or
$ script.pl search.txt replace.txt *.cstol

You can tweak $search's content as the linked node did if you so desire (but get rid of \Q if you do).


Comment on Re: Using Perl Regex to find & replace large chunks in code
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (555 votes), past polls