use strict; use threads; use Win32::OLE; my $threadNum = 2; my $directoryLocation = 'C:\Users\nate\Desktop\websites';# opendir(DIR, $directoryLocation); my @files = grep(/\.html$/,readdir(DIR)); closedir(DIR); my @threads; my $counter = 0; for(1..$threadNum){ my @fileSlice = @files[$counter..$counter+$#files/$threadNum]; push @threads, threads->create(\&convertToWord,@fileSlice); $counter += $#files/$threadNum+1; } $_->join for(@threads); sub convertToWord(){ my $Word = Win32::OLE->new('Word.Application', 'Quit'); #convert some stuff to wordXML here, not shown to save space }