Your question has already been answered but I thought someone should clue you in to how -i works and why the suggestion was to use perl -pi -e rather than perl -pie which seems, at first glance, to be the tastier option(s).

The reason the otherwise delectable -pie wasn't suggested was because it wouldn't work.

The -i takes an optional argument. A rather useful argument at that. If given, perl renames the original file by appending the argument as a suffix to the filename, thereby preserving it if you make any mistakes in your one-liner. Trust me. If you use it, you will eventually find this feature useful. If you fail to use it, you will eventually wonder why you didn't. Out of habit, I would write your one-liner as:

perl -pi.bak -e 's/text/newtext/g' /path/to/file

So, anyway, if given -pie perl would is forced to... errrr... eat the 'e' as the backup suffix. Sadly though, "e" isn't usually a very useful suffix.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: simple text substitution. by sauoq
in thread simple text substitution. by Anonymous Monk

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.