Your script didn't work because exec doesn't return anymore after it executes the rm and mv commands. Note that the error message gives a strong hint when it tells you that you probably wanted to call system() instead of exec.

This is something to remember, especially if you don't have the motivation to learn beforehand: Always inspect error messages, they are here to tell you something and often (as in this case) they give you a hint what you have to look up to understand the problem

Update: You also might want to add http:// only when it is necessary:

$line= 'http://' . $line if (not $line=~/^http:/); print $new $line;

In reply to Re: File manipulation only works when I split it into two files. by jethro
in thread File manipulation only works when I split it into two files. by Vonunov

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.