Moving a file to another directory in Perl? -
rename $argv[0], $argv[1] or warn "rename fails: $!\n";
when run ./programe file.txt dir/
fails.
what's wrong here?
from perldoc rename:
behavior of function varies wildly depending on system implementation. example, not work across file system boundaries, though system mv command compensates this. other restrictions include whether works on directories, open files, or pre- existing files. check perlport , either rename(2) manpage or equivalent system documentation details.
for platform independent "move" function @ file::copy module.
so use file::copy::move instead.
Comments
Post a Comment