There are two possibilities: 1) It's unable to copy some of the files because of a permissions issue or some other filesystem restriction (but this should produce errors), or 2) it's not always doing what you think it's doing.

To investigate the second possibility, add some print statements to your code that show what it's doing, like this:

print "Copying '$source' to '$destination'\n"; copy($source,$destination) or die $!;

I put single quotes around the filenames so any whitespace in the names will be apparent. Make sure you print the same arguments that you're passing to the copy() routine, and then you'll be able to see if they are what you expect them to be. This is a very simple debugging method: when your program isn't doing what you expect, check the values of the variables that control its behavior.

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.


In reply to Re: Perl - Copy files to a newly created folder by aaron_baugher
in thread Perl - Copy files to a newly created folder by Benichouniev

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.