Perl: Loop through a file and substitute

Mark Froland picture Mark Froland · Jun 1, 2009 · Viewed 7.5k times · Source

I simply wanna read in a logfile, do a search and replace, and then write out the changes to that same logfile.

What's the best practice way of doing this in Perl?

Answer

Todd Gardner picture Todd Gardner · Jun 1, 2009

I normally code up a one liner for this:

perl -i -pe 's/some/thing/' log.file

See Here