$ perl mycode.pl filename > ~/MyPerl/result_ans/filename.out
####
perl("mycode.pl filename > ~/MyPerl/result_ans/filename.out");
####
use Shell;
use Proc::Queue size=>5, qw(run_back);
my @list = glob("*.fasta");
foreach my $list (@list) {
run_back { run_code($list) }
}
sub run_code {
my $fname = shift;
my $base = ( split( /\./, $fname ) )[0];
perl("mycode.pl $base > ~/MyPerl/result_ans/$base.out");
# Tried this too, but still doesn't work
# system("perl mycode.pl $base > ~/MyPerl/result_ans/$base.out");
return ;
}
1 while wait != -1;
####
use Parallel::ForkManager;
use Shell;
my @list = glob("*.fasta");
my $pm = new Parallel::ForkManager(10);
foreach my $list (@list) {
my $pid = $pm->start and next;
my $base = ( split( /\./, $list) )[0];
system("perl mycode.pl $base > ~/MyPerl/result_ans/$base.out");
$pm->finish; # Terminates the child process
}