I know the header sounds funny.

I want to replace all instances of a particular string in a file from a script. To do this I'm using "perl -pi -e" from a perl script which does a lot of things internally.

Now I want to check the return status of the "perl -pi -e" command. To test this i removed the permissions on the destination file and then ran the script. The system command still returns me a status "0" which implies that the command ran successfully. I think the command should have failed and given some other return status. May be I'm missing something here.

Can you let me know how to get the return status of the "perl -pi -e" command?

Also, I'd like to know other ways to accomplish the same task instead of doing a system call for "perl -pi -e".

Thanks, Nikhil

In reply to Executing "perl -pi -e" in perl script by nbokare

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.