Dear Monks,

I have a script which forks 3 childs at a given time and this is taken care by Proc::Queue.
Everything worked fine until I moved the line "next if" above the Proc::Queue::run_back_now{} method

After the above change the script spawns unlimited childs. For example, I have an array of 50 files
the script spawns 50 childs.

Is this the problem of Proc::Queue or is this script error. Below is my code
#!/usr/bin/perl -w use POSIX 'WNOHANG'; use Proc::Queue ':all'; use Getopt::Long 'GetOptions'; my $numChilds=3; GetOptions( 'childs|c=i' => \$opt_numChilds , 'help|h' => \&USAGE ) || USAGE() ; ($opt_numChilds) ? $numChilds=$opt_numChilds : $numChilds; Proc::Queue::size($numChilds); #update my $src="/data/files"; my @allfiles = ("$src/file1", "$src/file2", "$src/file3","$src/file4", +"$src/file5","$src/file6"); my $log = "/tmp/data.log"; open(STAT, $log) || die ("Can't open file $log: $!"); my @pids; foreach my $file (@allfiles) { my ($root=$file); ($root=$file)=~tr/a-z/A-Z/; next if (!-f"$srcdir/ok"); push @pids, Proc::Queue::run_back_now{ #code here system("dataload.pl -file $file > file.err 2>&1"); }; } waitpids(@pids); close STAT; exit;
Many thanks

In reply to Is this Proc::Queue error by chanakya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.