On Wed, Mar 2, 2016 at 5:40 AM, Arghya Das <arghya0...@gmail.com> wrote:
> #copies 1 file to another > > use warnings; > > use File::Copy; > > copy("FILE1.txt","new_file.txt"); > > > > This script works if FILE1.txt is in current directory of windows but when > i try to give a full path to a file like : "C:\Folder1\FILE1.txt" it doesnt > work. > > This is the same with rename and unlink functions of perl; > > > please help. > The backslash (\) is used as an escape character. In order to use backslashes, you would have to escape the backslash ("C:\\Folder1\\FILE1.txt"). Or you can use forward slashes ("C:/Folder1/FILE1.txt" ). You should also check for errors. For example (untested): my $file1 = 'FILE1.txt'; my $file2 = 'FILE2.txt'; copy( $file1, $file2) or die "Unable to copy $file1 to $file2: $^E"; HTH, Ken