Perl Multiple search and replace actions in one large text file

Viewed 923

Given a set of replacement strings in a file replacements.txt like

s/string1/replacement1/g;
s/string2/replacement2/g;
s/string3/replacement3/g;
s/string4/replacement4/g;
s/string5/replacement5/g;

I would like to obtain the equivalent of

sed -f replacements.txt infile.txt 

my file is so big that sed cant handle it, while I know that perl could do the trick.

Also the replacements are really a lot, and change from time to time. ( I need to run this a dozen of times)

Note that the replacements are fixed strings, so I do not really need those to be regular expressions.

sed has problems only when the regexp has globs and the input file is a single large line.

1 Answers
Related