Perl File Copy
In this tutorial, we are going to learn on how to copy a file using Perl. You can script this process, which can be really handy while doing automation, backups, deployments, staging etc.
Perl has a module which we can use to copy file
To use this function in Perl we need to use the following syntax:
Lets create a file name example.txt and enter some text.
Now use copy function to copy the file.
copy ("filename" "copiedfilename")
Make sure you use the space between copy filename newfilename
The script below shows how to copy a file.
# Perl copy module
# Perl syntax to copy a file, where example.txt is orignal file name
copy ("example.txt", "copiedexample.txt");
exit; #Script will exit now
example.txt is copied to copiedexample.txt