Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move Directory in perl

Tags:

perl

I am trying to move a directory using perl within the same volume in ubuntu.

I used the move ( File::Copy ) command in Perl like below

move($dir1, $dir2);.  # Doesn't work.

Expecation is that $dir1 will be place under $dir2 after the move. But got an error saying that 'Is a directory'.

But when I use system mv it works perfectly.

system("mv $dir1 $dir2"); #This works!.

I searched google and understood that move should works exactly like mv in linux?. Any ideas?

like image 599
yogi_en Avatar asked Dec 11 '22 19:12

yogi_en


1 Answers

If you want to move the directory ./dir1 under ./dir2 call move like this:

move("./dir1", "./dir2/dir1");

I think you are doing:

move("./dir1", "./dir2/");

which complains because ./dir2 already exists.

like image 68
perreal Avatar answered Jan 02 '23 10:01

perreal