#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Can you please tell me what are the functions to copy files and directories in Perl?

    ------------------
    ahs
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    There is no "copy" function in Perl. However, there are two ways to copy files or dirs in Perl:

    1) File::Copy
    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.

IMN logo majestic logo threadwatch logo seochat tools logo