Perl File::Copy ERROR
Szeretném egy állományban (T.txt) letárolt file nevek alapján a file-okat másolni.
Teszem ezt így:
# Perl 5.8.8 version on Debian
#!/usr/bin/perl
use File::Copy;
use Cwd;
use strict;
chdir ("/Dir_PATH");
my $basedir = "/Dir_PATH";
my $TFILE = "$basedir/T.txt";
my $line = "";
my $cwd = getcwd();
#print "$cwd\n";
open(FILE, "$TFILE") or die("Could not open $LOGFILE file.");
foreach $line () {
my $dircopy = "$basedir/COPY/$line";
#print "$line\n";
copy ($line, $dircopy);
#system ("cp $line $dircopy");
}
close (FILE);
Ez lesz belőle:
Unsuccessful stat on filename containing newline at /usr/share/perl/5.8/File/Copy.pm line 85, line 3.
at /usr/share/perl/5.8/File/Copy.pm line 85
File::Copy::copy('filename.jpg\x{a}', '/Dir_PATH/COPY/filename.jpg\x{a}') called at ./masolda.perl line 18
Unsuccessful stat on filename containing newline at /usr/share/perl/5.8/File/Copy.pm line 95, line 3.
at /usr/share/perl/5.8/File/Copy.pm line 95
File::Copy::copy('filename.jpg\x{a}', '/Dir_PATH/COPY/filename.jpg\x{a}') called at ./masolda.perl line 18
Unsuccessful open on filename containing newline at /usr/share/perl/5.8/File/Copy.pm line 122, line 3.
at /usr/share/perl/5.8/File/Copy.pm line 122
File::Copy::copy('filename.jpg\x{a}', '/Dir_PATH/COPY/filename.jpg\x{a}') called at ./masolda.perl line 18
main::(./masolda.perl:16): my $dircopy = "$basedir/COPY/$line";
Rendszer híváson keresztüli cp-vel sem jobb a helyzet:
system ("cp $line $dircopy");
cp: missing destination file operand after `filename.jpg'
Try `cp --help' for more information.
sh: line 1: /Dir_PATH/COPY/filename.jpg: No such file or directory
main::(./masolda.perl:16): my $dircopy = "$basedir/COPY/$line";
Viszont ha nem listából olvasva, hanem manuálisan etetem a copy / system cp függvényt akkor minden OK !?!?!?
Valamit benézek? system cp / copy függvény nemképes listából olvasva működni?
Rossz a módszer?
Köszi a szakértést!
- Tovább (Perl File::Copy ERROR)
- 1319 megtekintés