perl copy command

aueddonlineaueddonline Member Posts: 611 ■■□□□□□□□□
This is the code I have which is currently not working, i'm getting 'File cannot be copied. at copy line 8.' which is the last line of code.


use File::Copy;

$file = "C:\Users\xps\Documents\test.";
$newfile = "C:\Users\xps\Documents\test2.";

copy ($file, $newfile) or die "File cannot be copied.";
What's another word for Thesaurus?

Comments

  • dynamikdynamik Banned Posts: 12,312 ■■■■■■■■■□
    Try changing the last line to:
    copy ($file, $newfile) or die "File cannot be copied: $!";
    

    The $! will spit out the actual error message and may help you identify the problem. It might be a permission issue or something like that. I don't know perl very well; sorry I can't be of more assistance.
  • aueddonlineaueddonline Member Posts: 611 ■■□□□□□□□□
    dynamik wrote:
    Try changing the last line to:
    copy ($file, $newfile) or die "File cannot be copied: $!";
    

    The $! will spit out the actual error message and may help you identify the problem. It might be a permission issue or something like that. I don't know perl very well; sorry I can't be of more assistance.

    you and me both, got this with the $!

    Scalar found where operator expected at copy line 6, near ""File cannot be copied." $!"
    (Missing operator before $!?)
    syntax error at copy line 6, near ""File cannot be copied." $!"
    Execution of copy aborted due to compilation errors.
    What's another word for Thesaurus?
Sign In or Register to comment.