find -name '*.fasta' -maxdepth 1 -print0 \ | xargs -r -0 -P5 -n1 sh -c 'perl mycode.pl "$1" > ~/MyPerl/result_ans +/"$1".out' ''
Whenever you find yourself thinking “I want to start a bunch of processes like this one with different parameters,” xargs probably has your back. When it involves files, find -print0 | xargs -0 is the standard tool.
Or else you put parallelism into your main script itself – the feasibility of that varies. (In your case it would have to be adapted to create output logfiles per some sort of filename template.)
Makeshifts last the longest.
In reply to Re: Running a Perl Code within a Perl Code Using "Shell Module"
by Aristotle
in thread Running a Perl Code within a Perl Code Using "Shell Module"
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |