in reply to Re: file is not getting copied
in thread file is not getting copied

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 ?

Replies are listed 'Best First'.
Re^3: file is not getting copied
by Corion (Patriarch) on Jul 17, 2011 at 17:20 UTC

    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
        ... at C:\Users\Admin\Desktop\perl_programs\copyfn.pl line 7

        means that the error was found when Perl ran the line number 7 in the named program. This has nothing to do with $copy_from or $copy_to, but it helps you to know what command failed.