monkfan has asked for the wisdom of the Perl Monks concerning the following question:
Now, I want to run this command again but within a Perl code, using Shell module. Here is the snippet of how I do it:$ perl mycode.pl filename > ~/MyPerl/result_ans/filename.out
But this doesn't work. Why?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 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running a Perl Code within a Perl Code Using "Shell Module"
by BrowserUk (Patriarch) on Nov 10, 2005 at 03:47 UTC | |
|
Re: Running a Perl Code within a Perl Code Using "Shell Module"
by Aristotle (Chancellor) on Nov 10, 2005 at 03:37 UTC | |
by monkfan (Curate) on Nov 10, 2005 at 04:01 UTC | |
by Aristotle (Chancellor) on Nov 10, 2005 at 04:06 UTC | |
|
Re: Running a Perl Code within a Perl Code Using "Shell Module"
by salva (Canon) on Nov 10, 2005 at 11:13 UTC | |
|
Re: Running a Perl Code within a Perl Code Using "Shell Module"
by dragonchild (Archbishop) on Nov 10, 2005 at 03:29 UTC |