#!/usr/bin/perl use strict; use warnings; open (FH,"; my $files = \@file_lists; m_fork(5,$files,\&dbv_check); sub dbv_check { my ($file,$logfile)= @_; system ("dbv","file=$file","blocksize=8192","logfile=$logfile"); } sub m_fork { my ($max,$file_list,$dbv_command) = @_; my $count = 0; foreach my $file_name (@$file_list) { wait if $count>$max; die "error\n" unless defined(my $pid = fork()); exit $dbv_command->($file_name,$count) unless $pid; $count ++; } }