October 17th, 2000, 12:28 AM
Can you please tell me what are the functions to copy files and directories in Perl?
October 17th, 2000, 02:39 AM
There is no "copy" function in Perl. However, there are two ways to copy files or dirs in Perl:
Copy.pm should came with your Perl by default.
2) Using "cp" command in UNIX within backtick operators. "man 1 cp" to find out the usage yourself, you are on your own with this.
i.e. `cp $old_file $new_file`; #where both variables should have full system path.
Just so you know, Copy.pm simply uses "cp" command in UNIX so you may go ahead and use "cp".
Keep in mind, you need to watch for permission. For $old_file, you, the user Apache runs as, need to have read access while the directory where $new_file resides need to have write permission. For example, if Apache is run as nobody, then that directory needs to have 777 permission.