in reply to Re: help needed in File::copy
in thread help needed in File::copy

dear monks, copy("c:\\dir1\\text.errmsg", "c:\\dir2\\text.errmsg") || die "Can't open text.errmsg:$!"; when i ran the program, it creates the file and copied the content. next time i ran the program (destination file is existing now ) it is giving error message. Normally it should overwrite it ,but it is not happening here.. can u explain in detail??

Replies are listed 'Best First'.
Re^3: help needed in File::copy
by izut (Chaplain) on Mar 01, 2006 at 12:51 UTC

    copy will check if the destination file exists. I don't think exists a parameter for overwrite destination file. Maybe you want this:

    unlink $destfile if -f $destfile; copy($origfile, $destfile);

    Update: This is a workaround. As mickeyn said at Re: help needed in File::copy, File::Copy should overwrite destination file.

    Igor 'izut' Sutton
    your code, your rules.