I'm new to Perl and trying to access several directories at the same time and simply read the content of the director and do some processing on the files in those directories. The code below is a reference code to get started on the real work. The code below however crashes and I'm lost as to what these cause is. Any help you could give me I'd appreciate it. This code simple in that it looks for 3 letter directories and creates a stat file used to report the files in that directory. Eventually I'll want to do is run those files through processing and take advantage of a bitching 8 processor machine we just got. BTW I'm using Perl 5.6 on win 2000 machine (ActivePerl-5.6.0.623-MSWin32-x86-multi-thread to be exact).
#code starts use threads; $currDir = `cd`; chop($currDir); opendir(IP_MAIN_DIR, $currDir); #remove '.' and '..' @allBatchFolders = grep !/^\.\.?$/, readdir IP_MAIN_DIR; #get the names of all the 3 character directories in to a list/array ("aaa" and "aab, and "aac" qualify) @allBatchFolders = grep /^[a-z][a-z][a-z]$/, @allBatchFolders; #open stat file for writing open(STATFILE, ">$currDir\\stat.txt"); $index = 0; foreach $aDir (@allBatchFolders) { $aThread[$index] = threads->new(\&writeStat, $aDir); @ReturnData = $aThread[$index]->join(); $index++; } closedir(IP_MAIN_DIR); close(STATFILE); sub writeStat { $localDir = $currDir . "\\" . $_[0]; local *DIRECTORY; opendir(DIRECTORY, $localDir); print "Start wile loop: @_[0]\n"; print STATFILE "Start wile loop: @_[0]\n"; rewinddir( DIRECTORY ); while ($file = readdir(DIRECTORY)) { writeToFile(@_[0], $file); } print STATFILE "End wile loop: @_[0]\n"; print "End wile loop: @_[0]\n"; closedir(DIRECTORY); } sub writeToFile { use attrs qw(locked); print STATFILE "Thread @_[0]: @_[1]\n"; } #code ends -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]