Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: help needed in File::copy

by uva (Sexton)
on Mar 01, 2006 at 12:25 UTC ( [id://533632]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://533632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2025-01-22 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (63 votes). Check out past polls.