Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to copy a file and force overwirte in perl

Reply
Thread Tools

How to copy a file and force overwirte in perl

 
 
Jay@HK
Guest
Posts: n/a
 
      11-30-2006
I have to write a perl script to copy and overwrite a file,
I tried to use file::copy but it seems no options for force overwrite
the destination file.
please advise.

Thanks!

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      11-30-2006
Jay@HK wrote:
> I have to write a perl script to copy and overwrite a file,
> I tried to use file::copy but it seems no options for force overwrite
> the destination file.
> please advise.


What are you talking about? File::Copy *does* overwrite the
destination file.

$ cat > file1.txt
THIS IS FILE ONE
$ cat > file2.txt
this is the second file
$ perl -MFile::Copy -e'copy "file1.txt", "file2.txt"'
$ cat file2.txt
THIS IS FILE ONE
$

Paul Lalli

 
Reply With Quote
 
 
 
 
Dr.Ruud
Guest
Posts: n/a
 
      11-30-2006
Jay@HK schreef:

> I have to write a perl script to copy and overwrite a file,
> I tried to use file::copy but it seems no options for force overwrite
> the destination file.
> please advise.


s/file::copy/File::Copy/

--
Affijn, Ruud

"Gewoon is een tijger."
 
Reply With Quote
 
Stan R.
Guest
Posts: n/a
 
      12-01-2006
Paul Lalli wrote:
> Jay@HK wrote:
>> I have to write a perl script to copy and overwrite a file,
>> I tried to use file::copy but it seems no options for force overwrite
>> the destination file.
>> please advise.

>
> What are you talking about? File::Copy *does* overwrite the
> destination file.
>
> $ cat > file1.txt
> THIS IS FILE ONE
> $ cat > file2.txt
> this is the second file
> $ perl -MFile::Copy -e'copy "file1.txt", "file2.txt"'
> $ cat file2.txt
> THIS IS FILE ONE
> $
>
> Paul Lalli


It's most like a permissions problem (which is why it's always good to
check return statuses & $!)

--
Stan


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM



Advertisments