use forks; my $max_threads = 30; for( 1...$max_threads ) { threads->create( \&munge_files, shift(@files_to_munge) ); }# end for() # Wait for our threads to finish: $_->join foreach threads->list; # All done! print "Job was completed.\n"; sub munge_files { my ($file) = @_; # Do stuff with $file... }