M626
Programmer
- Mar 13, 2002
- 299
I am having a problem with this script. I connect to a mapped drive and test against a text file(listDir.txt) if those files listed in the text file are in the directory. if there is a file that is in the directory but not on the list, it get deleted. My problem is the drive become unavailable for a about 30 seconds sometimes because of congestion, is there a way i can have the script retry after so many seconds if it looses connection?
#------Start of Script-------
#!/usr/bin/perl
use File::Basename qw(basename);
use Tie::File;
use File::Copy;
use strict;
my $datafile = 'C:\Temp_83/listDir.txt';
my $datadir = 'T:\DataFiles';
tie my @array, 'Tie::File', $datafile or die "Can't open $datafile: $!";
my %files = map {basename($_) => 1} grep {! /^\s*$/} @array;
untie @array;
open(OUTFILE, "> C:/TEMP_83/DeletedFiles.log") or die "can't open outfile : $!\n";
for (grep {!$files{basename($_)}} glob("$datadir/*")) {
unlink or die "Can't unlink $_: $!";
print OUTFILE "$_\n";
}
#------Start of Script-------
#!/usr/bin/perl
use File::Basename qw(basename);
use Tie::File;
use File::Copy;
use strict;
my $datafile = 'C:\Temp_83/listDir.txt';
my $datadir = 'T:\DataFiles';
tie my @array, 'Tie::File', $datafile or die "Can't open $datafile: $!";
my %files = map {basename($_) => 1} grep {! /^\s*$/} @array;
untie @array;
open(OUTFILE, "> C:/TEMP_83/DeletedFiles.log") or die "can't open outfile : $!\n";
for (grep {!$files{basename($_)}} glob("$datadir/*")) {
unlink or die "Can't unlink $_: $!";
print OUTFILE "$_\n";
}