in reply to Re: File::Copy Problem on Mac OS X
in thread File::Copy Problem on Mac OS X

hi, thanks for your reply to all of you.

The sample I gave was more for testing. In my real project I get the source url from a database.
I pass them also quoated to copy(), but I always get this error ($!): (No such file or directory)

If I print source and target URL to check if they are quoted I get:
source: '/Users/ademmler/testing mit leerzeichen/myfile.pdf'
target: '/Users/wfdata/myfile.pdf'

I have tried to use singel and double quotes . . . no change.
Mac OS X escapes the blank with \ and if I pass the path to my above testscript like this it works also. But if I try to add a \ via regex into the URL it does not work . . .

Regards Alex

Replies are listed 'Best First'.
Re^3: File::Copy Problem on Mac OS X
by marto (Cardinal) on Jun 03, 2008 at 12:25 UTC
    ademmler,

    Firstly, these are not URLs the are paths to files.

    Secondly, are you sure you have permissions to read from/write to the source file and target directory? Please show us the code you are actually using, and how you are calling it. Have you tried quoting the parameters you are passing to the copy command?
    #!/usr/bin/perl use strict; use warnings; use File::Copy; my $source = $ARGV[0]; my $target = $ARGV[1]; copy("$source", "$target") or die "Can't copy files ($!)\n"
    Update: Fixed typo, reworded last sentence. Hope this helps

    Martin
      eh? "$source" creates a string that's a copy of $source. Why would you do that? Not only does @ARGV contain strings, this will happen implicitly if copy requires them to be strings.
      Hi - thank you all again.

      #Firstly, these are not URLs the are paths to files.
      Yeah you are right -sorry for using the wrong wording.

      #Secondly, are you sure you have permissions to read from/write to the source file and target directory?
      Yes I am, I can copy them from the shell . . .

      #Please show us the code you are actually using, and how you are calling it.
      Sorry, I cant - It is one line within a complete project with Database, daemons, WebGUIs etc. . .
      to big, therefore I have provided the stripped down sample file.

      #Have you tried quoting the parameters you are passing to the copy command?
      Yes - without succsess . . .

      Seems like there is a difference in my File::Copy from Perl 5.8.6 and the one from perl 5.10
      We are just checking this . . . Regards Alex