A correction to the code for 1 line below :-(
Chris
Hello Brian,
I did what you wanted to do on my computer, (Windows XP). The code is
pasted below, followed by some explanations. You should be able to get the
same results by plugging in abc and xyz where I had html and txt. Also,
with source and target directories of your choosing.
#!/usr/bin/perl
use strict; use warnings;
use File::Copy;
my $source = "/Run";
my $target = "/temp";
my $filecount;
opendir DH, $source or die "Unable to open directory $source: $!;
for (readdir DH) {
next unless /html?$/ && -s;
next unless /html?$/ && -s "$source/$_";
print "The fileneme is $_\n";
(my $txt = $_) =~ s/html?$/txt/; copy("$source/$_", "$target/$txt");
$filecount++;
}
close DH;
print "$filecount files copied\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>