G'day 5plit_func,

Look at readdir for better and more concise ways to achieve what you're doing with respect to getting a listing of files. I suspect the two shifts are to remove the current and parent directories (i.e. '.' and '..'): the grep in the first example removes the need for these statements as well as the additional map in your code.

I'd recommend using the autodie pragma to check for problems (including opendir and unlink). The alternative is to hand-craft explicit checks throughout your code: this is time consuming, a lot more work and error-prone.

If the errors that now show up do not help you, please post them here so that we can see them. While it's good that you've posted your code, without seeing the output, error or otherwise, we're somewhat in the dark with regards to being able to provide help. [Take a look at the guidelines in "How do I post a question effectively?" if you're unsure what to post.]

If you're not doing this already, I'd strongly recommend setting up a test directory (perhaps with a script to recreate it) for trying out your code while you're in development mode. It's all too easy to accidently delete the wrong (possibly important) files.

-- Ken


In reply to Re: unable to delete dat files from a folder in windows all users/norton folder by kcott
in thread unable to delete dat files from a folder in windows all users/norton folder by 5plit_func

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.