in reply to In place editing of text files

ok some years have passed, but I don't see File::Slurp mentioned here which provide edit_file and edit_file_lines.
# replace all occurrences in the file edit_file { s/foo/bar/gs } myfile.txt> # replace occurrences a line at a time edit_file_lines { s/foo/bar/g } myfile.txt>
that said, I see Tie::File mentioned here which looks like a better solution for my case.

Replies are listed 'Best First'.
Re^2: In place editing of text files
by choroba (Cardinal) on Jul 23, 2016 at 07:49 UTC
    File::Slurp is no longer recommended. TLDR: It doesn't work well with encodings, is poorly maintained, and its default options are seldom needed.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,