in reply to [RFC] File::Replace

Well, I dove into the rabbit hole that is tieing ARGV in order to overload Perl's magic <> operator... quite an adventure, but at least I have something to show for it:

The former is probably only interesting if you want to implement your own module that overloads ARGV, while the latter is hopefully something interesting: It's a drop-in replacement for Perl's -i switch:

$ echo -en "hello\nworld\n" >foo.txt $ perl -i -ple '$_ = ucfirst' foo.txt $ cat foo.txt Hello World $ echo -en "quz\nbaz\n" >bar.txt $ perl -MFile::Replace=-i -ple '$_ = ucfirst' bar.txt $ cat bar.txt Quz Baz

So what's the advantage of this, especially given that -i's behavior was recently updated to operate in a fashion similar to File::Replace? Well, the above works on older Perls too (on *NIX, I've tested all the way down to 5.8.1, although I recommend ≥5.16, and on Windows I do have a bit more trouble testing, but it should work down to at least 5.10). This should be an advantage since you get guaranteed behavior even if you're not sure whether the box you're currently on has 5.28+ installed. Also, File::Replace is a lot more stringent in its checks, every step is checked for errors, which are generally fatal.