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

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

Replies are listed 'Best First'.
Re^4: move() error
by JKasting (Novice) on Feb 27, 2010 at 21:08 UTC
    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?