File::Copy woes

Discussion in 'Perl Misc' started by frisina@gmail.com, Dec 10, 2004.

  1. Guest

    Hi all:


    I am writing some code in which I want to copy a file to a directory
    periodically, and replace the existing file of the same name when it
    does indeed exist. Is there any way to do this with File::Copy? It
    seems to not replace if the file exists.

    Help?

    Thank you,

    Francis
     
    , Dec 10, 2004
    #1
    1. Advertising

  2. James Tolley Guest

    > I am writing some code in which I want to copy a file to a directory
    > periodically, and replace the existing file of the same name when it
    > does indeed exist. Is there any way to do this with File::Copy? It
    > seems to not replace if the file exists.


    It replaces the file for me on XP, perl 5.8.3, File::Copy 2.07
     
    James Tolley, Dec 10, 2004
    #2
    1. Advertising

  3. Paul Lalli Guest

    <> wrote in message
    news:...
    > I am writing some code in which I want to copy a file to a directory
    > periodically, and replace the existing file of the same name when it
    > does indeed exist. Is there any way to do this with File::Copy? It
    > seems to not replace if the file exists.


    Your diagnosis is incorrect. File::Copy has no more trouble overwriting
    an existing file than the cp system command. What is the error message
    you are receiving? You *are* checking for the error message, aren't
    you?

    use File::Copy;
    copy ('file.txt', 'otherdir/file.txt') or die "Cannot copy: $!";

    As a hunch, I'd bet you don't have the needed permissions on the target
    to overwrite the file.

    Paul Lalli
     
    Paul Lalli, Dec 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter
    Replies:
    4
    Views:
    5,508
    Steve Richter
    Apr 18, 2005
  2. Alex
    Replies:
    2
    Views:
    1,256
  3. Replies:
    26
    Views:
    2,140
    Roland Pibinger
    Sep 1, 2006
  4. dave
    Replies:
    6
    Views:
    1,054
  5. MaggotChild

    File::Copy::copy With File Handles

    MaggotChild, Oct 18, 2011, in forum: Perl Misc
    Replies:
    2
    Views:
    518
    Ilya Zakharevich
    Oct 22, 2011
Loading...

Share This Page