Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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).

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 chilling in the Monastery: (6)
As of 2016-06-26 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (327 votes). Check out past polls.