auto.pl!!...execute this file alone!
system "ls -1 /home/input/ > /home/list";
my @test = ();
@array=qw{1.pl 2.pl};
foreach $i(@array)
{
my $pid = fork();
if($pid==0)
{
#child
system "perl ".$i
;
exit(0);
}
elsif($pid)
{
#parent
push(@test,$pid);
}
}
foreach (@test)
{
waitpid($_,0);
}
1.pl!!!!!!!!
my @array=();
my %hash=();
open (LIST, "</home/list");
@array= <LIST>;
close LIST;
foreach (@array){
chop($_);
}
$len=@array;
$rc=0;
$i=0;
$y=0;
begin: while($i<$len)
{
while($rc<3)
{
my $rcpid= fork();
if($rcpid==0)
{
system "/home/x.pl $array
$i";
print "child".$i."\n";
exit(0);
}
elsif($rcpid)
{
print "Parent ".$rcpid."\n";
push(@kick,$rcpid);
$rc++;
$a = $array
$i;
$hash{ $i } = $a;
$i=$i+2;
}
}
$x=$i-6;
if($rc==3)
{
while($x < $i)
{
$temp=$array
$x.".out";
if (-e "/home/$temp")
{
delete $hash{$x};
$rc--;
print "inside begin\n";
goto begin;
break;
}
else
{
$x=$x+2;
}
}
}
foreach (@kick)
{
waitpid($_,0);
}
sorry couldnt figure out how to give the spaces at the beginning of the line...and not a lot of time too...my apologies to fellow monks...this can be extended to any numbers...i have given example of 1.pl...you can do this till n i guess and also you can change the number of forks per file....hope this aint bad perl hacking...:-s ...cheers
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.