Reputation: 3835
I have this script to move files but it keeps saying that the files are identical and therefore they cannot be written
while (my @row = $sth->fetchrow_array) {
my $id = $row[0];
my $hash = $row[1];
my $input_direction = '/home/input/' . $hash;
my $output_direction = '/var/storage/'.$id;
opendir(my $dir, $input_direction);
while(my $file = readdir $dir){
next if ($file eq "." or $file eq "..");
my $from = $output_direction . "/" . "$file";
move($from, $output_direction);
}
}
Here are the errors:
'/var/storage/5/.bashrc' and '/var/storage/5/.bashrc' are identical (not copied) at Move_Files.pl line 38.
Use of uninitialized value $atime in utime at /usr/share/perl5/File/Copy.pm line 393.
Use of uninitialized value $mtime in utime at /usr/share/perl5/File/Copy.pm line 393.
This repeats itself a few times with each file and nothing gets copies.
Any idea?
Upvotes: 0
Views: 170
Reputation: 386551
my $from = $output_direction . "/" . "$file";
should be
my $from = $input_direction. "/" . "$file";
Better yet:
my $from = $input_direction. "/" . $file;
Upvotes: 3
Reputation: 242198
Check the code:
my $from = $output_direction . "/" . "$file";
move($from, $output_direction);
You probably wanted to use $input_direction
on the former line.
Upvotes: 3