Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
Here's my first attempt:
$batch_dir = "batch/"; $log_dir = "batchlog/"; while (1) { opendir( D, $batch_dir ) or die; print "checking $batch_dir for files\n"; @batchfiles = grep { !/^\./ } readdir(D); unless (@batchfiles) { print "Done: no more files to process\n"; exit; } # batchfiles contains all files at # most recent readdir() foreach $file (@batchfiles) { open( F, "$batch_dir$file" ) or die "$!"; while (<F>) { do_stuff_with($_); # actual processing omitted } close(F); rename("$batch_dir$file","$log_dir$file") || die "$!"; print "finished $file\n"; } }
Are there any problem, omissions, Traps for the Unwary in that that fellow monks can see?
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Batch Processing Files
by davido (Cardinal) on Jul 08, 2004 at 02:28 UTC | |
|
Re: Batch Processing Files
by ercparker (Hermit) on Jul 08, 2004 at 02:53 UTC |