in reply to Re^2: Oneliner replace in-place adds extra spaces at the end of the file
in thread Oneliner replace in-place adds extra spaces at the end of the file

The solution here isn't to switch the order of -l and -o, but to remove -l entirely.

Yes, that's a good point, in bliako's example the -l isn't needed, e.g. perl -i -0777pe 's/2/4/gs'.

In general, one might still want to use -0777 and -l together to change $\. A few more TIMTOWTDI examples doing that:

$ perl -MO=Deparse -0777l11ne ... BEGIN { $/ = undef; $\ = "\t"; } ... $ perl -MO=Deparse -l11n0777e ... BEGIN { $/ = undef; $\ = "\t"; } ... $ perl -MO=Deparse -ln0777e ... BEGIN { $/ = undef; $\ = "\n"; } ...