in reply to Re: move() error
in thread move() error

The error I'm getting says "No such file or directory" when I use the warning. However, I can verify that it does exist because I can find the file myself. I'm even printing out the old and new file paths when I run the script. It all seems to be correct. Suggestions?

Replies are listed 'Best First'.
Re^3: move() error
by toolic (Bishop) on Feb 26, 2010 at 18:52 UTC
    use strict and warnings and use lots of print's and file checks (-e):
    my @bookNameArray; my $bookName; my @bookFileName; for(my $h = 0; $h < scalar(@bookFiles); $h++){ @bookNameArray = split(/_/ , $bookFiles[$h]); @bookFileName = split("/" , $bookFiles[$h]); $bookName = $bookNameArray[-2]; my $newdir = $dir . "/Book Chapter/" . $bookName; print "newdir >>>$newdir<<<\n"; mkdir($newdir) or die "cant mkdir $newdir: $!"; my $src = $bookFiles[$h]; print "src>>>$src<<<\n"; my $dst = $dir . "/Book Chapter/" . $bookName . "/" . $bookFileName +[-1]); print "dst>>>$dst<<<\n"; if (-e $src) { print "$src exists\n"; } else { print "$src does not exist\n"; } # same -e check for dst move($src, $dst) or die "cant move : $!"; }
    See also Basic debugging checklist
      Ok, i've put all of those checks in. When it gets to the one that breaks the program, the "exists" check verifies that both the file and the directory exist. I've replaced all spaces with dashes as pileofrogs suggested, but that didn't help either. I'm really baffled here.

        I would run the script under strace (in case you're on Linux, that is — you haven't mentioned what platform you're using, and your usage of spaces in the paths makes me think you might not be).  This might help to figure out what exact system call is failing with "No such file or directory", which in turn might help to generate an idea what's going wrong...

        You say you've done these things, so where is the code?
Re^3: move() error
by Anonymous Monk on Feb 26, 2010 at 18:29 UTC
    Suggestions?

    Heed the error, its doesn't lie