Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Learning to use fork() (use Proc::Background)

by Anonymous Monk
on Jan 15, 2019 at 04:03 UTC ( [id://1228571]=note: print w/replies, xml ) Need Help??


in reply to Re: Learning to use fork()
in thread Learning to use fork()

It really feels messy and not clear

11_42

You're really asking how to clean 11_42? 11_42 you say? What is 11_42? Exactly!

1 use Proc::Background

#!/usr/bin/perl -- use strict; use warnings; use Proc::Background; my @jobs = ( [ $^X, 'job1.pl' ], [ $^X, 'job2.pl' ], [ $^X, 'job3.pl' ], [ $^X, 'job4.pl' ], [ $^X, 'job5.pl' ], [ $^X, 'job6.pl' ], [ $^X, 'job7.pl' ], [ $^X, 'job8.pl' ], [ $^X, 'job9.pl' ], [ $^X, 'job10.pl' ], [ $^X, 'job11.pl' ], [ $^X, 'job12.pl' ], [ $^X, 'job13.pl' ], ); my @procs = map { Proc::Background->new( @$_ ) } @jobs; while( @procs ){ @procs = { $_->alive ? $_ : ItsOverMaybeRestart($_) } map @procs; sleep 1; } sub ItsOverMaybeRestart { my( $proc ) = @_; ... return; }

Replies are listed 'Best First'.
Re^3: Learning to use fork() (use Proc::Background)
by AnomalousMonk (Archbishop) on Jan 15, 2019 at 04:51 UTC
    @procs = { $_->alive ? $_ : ItsOverMaybeRestart($_) } map @procs;

    I don't know anything about Proc::Background, but shouldn't that be something like

    @procs = map { $_->alive ? $_ : ItsOverMaybeRestart($_) } @procs;
    ?


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228571]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-26 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found