copy folder and its contents to another folder

Hi experts,

I am coming to you with this basic question on copying a folder and its content from one location to another folder using PERL script.

This is my requirement.

I have a folder AB under /users/myhome
I want to copy AB and its contents to /user/workspace.
Finally it should look like, /users/workspace/AB

How to do it using perl?

This is my code but its not working correctly as I don't see AB under /user/workspace, instead only contents of AB.

#!/usr/bin/perl 
#!/usr/bin/env perl -w
use strict;
use warnings;
use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);
dircopy("/users/myhome/AB","/users/workspace/") or die("$!\n");

Please help

Would there be a problem running up the unix cp command? You could fire off the statement:-

cp -R /users/myhome/AB /users/workspace

If your code is generally working but losing the top level structure, try an extra step to create the correct target directory first, then issue the copy fully specified to write to the newly created directory. I think that you are not asking it to create the directory too. Perhaps you just need to drop the trailing / from the dircopy command for /users/workspace target directory.

I hope that this helps,
Robin
Liverpool/Blackburn