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.


In reply to Re: [RFC] File::Replace by haukex
in thread [RFC] File::Replace by haukex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.