#!/usr/bin/perl
use warnings;
use Cwd;
$out = "outFile";
$newdir = $newdirectory;
open(TABLEA, "dirlist");
@tablea = <TABLEA>;
foreach $dir (@tablea) {
chomp @tablea;
chdir $dir;
print(cwd);
print "\n";
if (glob("*.txt")) {
system("mv $out $newdir");
}
}
If I add the chomp and I print the current working directory, the only directory that gets printed is the first directory, multiple times(as many times there are files in the main directory). Any other thoughts? Thanks. | [reply] [Watch: Dir/Any] [d/l] |
Can you add a use strict; at the beginning of your code? And where do you assign a value to $newdirectory? As the code stands it is undefined and therefore your target directory is not specified.
The chomp should be placed before the loop.
| [reply] [Watch: Dir/Any] [d/l] [select] |