in reply to Re^5: File::Find problems
in thread File::Find problems

All I am trying to do is move some files from an external usb drive to a directory on my computer that I enter on the command line when prompted.

In other words:

chomp(my $destination = <STDIN>);

Yes, I have given up on trying to understand what is going on. Does rename() send the string to the shell? Hence, the paths used as arguments for rename() need to have the spaces escaped? How many slashes do you need to produce a literal slash, 2, 4, 7?

Replies are listed 'Best First'.
Re^7: File::Find problems
by ikegami (Patriarch) on Jan 15, 2010 at 08:41 UTC
    <STDIN> doesn't read from the command line. The command line isn't even a stream. The command line is placed in @ARGV. If you're getting it via STDIN, typing
    $ foo.pl /Users/me/Pictures/a b c d
    is fine. If you're passing it via the command line, you'll need to convert the string into something a string literal your shell will interpret as the appropriate string. For bash, you can use
    $ foo.pl /Users/me/Pictures/a\ b\ c\ d $ foo.pl '/Users/me/Pictures/a b c d' # Use '\'' for single quotes $ foo.pl "/Users/me/Pictures/a b c d" # Will interpolate like Perl

      Sorry, I meant STDIN when I said the command line.

      Here is my new error:

      Cross-device link at 2perl.pl line 29

      Here is line 29:

      rename $_, $new_path or die "$!";

        Directories are lists of associations between names and files. Renaming a file just changes the directories. The file itself is untouched.

        Since directories in one partition/disk/system can't refer to files in another, you can't rename files from one partition/disk/system to another.

        To copy a file then delete the original, you can use File::Copy's move

Re^7: File::Find problems
by ikegami (Patriarch) on Jan 15, 2010 at 08:45 UTC

    Does rename() send the string to the shell?

    No

    Hence, the paths used as arguments for rename() need to have the spaces escaped?

    rename takes two strings, and they must be paths. You may need escaping to create the strings, but that's got nothing to with rename.

    How many slashes do you need to produce a literal slash, 2, 4, 7?

    Literal is what is typed, not what's produced. From what? Which slash?

      I've had enough. Goodnight. I just wasted 5 hours of my time trying to write the script in perl. Too tired to continue with this ill conceived idea.