Reputation: 811
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
Thanks
Upvotes: 0
Views: 1528
Reputation: 9520
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: $!";
Upvotes: 1