in reply to Re: Re: Evolution of a Perl Programmer (new backup script)
in thread Evolution of a Perl Programmer (new backup script)
Although I would use a hash for the excludes, instead of looping over an array for each file in the directory, especially since the most common case of a file not being in the exclude list would also be the slowest case.FILE: while (defined(local $_ = readdir(LS))) { foreach my $file (@$exc) { next FILE if ($_ eq $file); } my $file = $dir . $_; my $append = "tar -rf $tarfile $file 2>> $ERRORFILE"; system($append); print "\t$file\n"; }
I also recommend testing the readdir() assignment with defined, as I did above, so that the while loop will not stop prematurely if there's a file named '0'.
|
|---|