简体   繁体   中英

Perl: Directory Copy Using Windows

So I'm trying to write a script to copy a directory and all sub directories and files to another directory (using windows).

I know there are unreliable dependencies involved in this program (such as E: drive being available).

My script seems massively simple compared to some of the other examples I have come across (I don't know if it will copy all sub files and directories).

I am new to Perl and if this sort of thing is above a beginners ability then please don't hesitate to tell me.

My Script:

use 5.16.3;
use strict;

my $datestring = localtime();

my $orig="C:/Users/Simon/My Documents";
my $new="E:/Back Up/2014/$datestring";
use File::Copy::Recursive::dircopy $orig, $new or die "Copy failed: $!";

The actual problem I am sure of this:

syntax error at line 8, near "$new or"

Looking for

  1. an answer
  2. a resource to help me figure it out

Thanks

Just a little error with needing to use the module first:

use 5.16.3;
use strict;
use warnings;

# import the sub dircopy into your script
use File::Copy::Recursive qw(dircopy);

my $datestring = localtime();

my $orig = "C:/Users/Simon/My Documents";
my $new  = "E:/Back Up/2014/$datestring";

dircopy($orig, $new) or die "Copy failed: $!";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM