I have tested the paths, and they are fine as I used the perl mv command using File::copy module with the same variables. But can't understand why this doesn't work.
Non sequitur. Suppose that $from='foo' and $to='bar baz'. If you pass these arguments to F::C's mv(), then it will try to move the the file named foo to that called bar baz - with a space in it. If you do
system("mv $from $to");
as in your first post, a shell will be started which in turn will call the external mv program with the three cmd line arguments foo, bar and baz. (Well, upon a closer look to the docs it seems that it will call the shell only if there are shell metacharacters, but the final result won't change.) This may not be your case, but it serves as an instructive example. Alternatively use the LIST form of system, which will avoid the shell in any case and more likely do the Right Thing™ - and check its return value:
0 == system 'mv', $from, $to or warn "Something wrong: $?\n";
|