my @removed_files =  split, <STDIN>;

You have a comma after the split, so Perl is reading that as split(), <STDIN>, which will try to operate on the special variable $_, which is why you're getting that warning. If you want to read all the lines from STDIN and have each element of the array be one line, it's enough to say:

my @removed_files = <STDIN>; chomp(@removed_files);

I added the chomp to remove the newline that each line will have at the end. Also, I might suggest a different variable name for clarity, such as @files_to_remove, and also you should check the return value of unlink to see if it actually removed a file. For example:

my $removed = unlink($file); print "Removed $removed file(s).\n"; # - or - unlink($file) == 1 or die "Failed to unlink $file: $!";

In reply to Re^3: remove files by haukex
in thread remove files by catfish1116

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.