Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy an entire directory in Perl?

I need to copy entire directory to some location.

What is the best way to do so ? File::Copy copies only file by file as I saw it.

By the way I work under Windows.

Thanks for help.

like image 400
Night Walker Avatar asked Dec 08 '09 09:12

Night Walker


People also ask

How do I Copy a whole directory?

Alternatively, right-click the folder, select Show more options and then Copy. In Windows 10 and earlier versions, right-click the folder and select Copy, or click Edit and then Copy. Navigate to the location where you want to place the folder and all its contents.

How do I list all files in a directory in Perl?

If you want to get content of given directory, and only it (i.e. no subdirectories), the best way is to use opendir/readdir/closedir: opendir my $dir, "/some/path" or die "Cannot open directory: $!"; my @files = readdir $dir; closedir $dir; You can also use: my @files = glob( $dir .


2 Answers

Maybe look into File::Copy::Recursive.

like image 66
unwind Avatar answered Sep 28 '22 15:09

unwind


A quick google search for "perl copy directory file::" finds

File::Copy::Recursive

Looks what you're after.

like image 42
Adam Luchjenbroers Avatar answered Sep 28 '22 15:09

Adam Luchjenbroers