in reply to file is not getting copied

copy($copy_from, $copy_to) or die "Can't copy because: $!";

Replies are listed 'Best First'.
Re^2: file is not getting copied
by manishrathi (Beadle) on Jul 17, 2011 at 17:13 UTC
    C:\Users\Admin>perl C:\Users\Admin\Desktop\perl_programs\copyfn.pl Can't copy because: No such file or directory at C:\Users\Admin\Desktop\perl_programs\copyfn.pl line 7.

    Why am I getting this message ? My source file is located in "C:\Users\Admin\Desktop\staples" and thats where I am trying to copy it. So why am I getting this message ?

      That's not what your source code says:

      my $copy_from = "C:/Users/Admin/Desktop/Staples files/readfile.txt";

      This means that your source file is in C:/Users/Admin/Desktop/Staples files. I would assume that Perl is correct when it says that it cannot find the file.

        my $copy_from = "C:/Users/Admin/Desktop/Staples files/readfile.txt";
        This is the source

        Output message is
        C:\Users\Admin>perl C:\Users\Admin\Desktop\perl_programs\copyfn.pl Can't copy because: No such file or directory at C:\Users\Admin\Desktop\perl_programs\copyfn.pl line 7

        So why is Perl looking for readfile.txt in this location ? Obviously, readfile.txt is not located in perl_programs. When source path is provided, Perl should look into that source path.
        Please explain