0
我有這樣的腳本來移動文件,但它口口聲聲說文件是相同的,因此它們不能被寫入腳本移動文件將不會在Perl
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);
}
}
在這裏工作是錯誤的:
'/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.
這對每個文件重複幾次,沒有任何東西會得到副本。
有什麼想法?
http://perldoc.perl.org/perlfaq1.html#What's-the-difference-between-%22perl% 22-and-%22Perl%22%3f – Quentin
提示:'my $ id = $ row [0];我的$ hash = $ row [1];'可以寫成我的($ id,$ hash)= @row;' – ikegami
提示:'opendir'很可能會失敗,所以至少添加一個最小''或死$!'可以是有用的。 – ikegami