yogi_en
yogi_en

Reputation: 121

Move Directory in 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?

Upvotes: 4

Views: 15674

Answers (2)

hypo
hypo

Reputation: 76

use File::Copy::Recursive;
rmove('foo/bar/baz', '/etc/');

Upvotes: 0

perreal
perreal

Reputation: 97948

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.

Upvotes: 13

Related Questions