in reply to Creation of simultaneous system commands

Traditionally, one uses fork, or threads.

Abigail

  • Comment on Re: Creation of simultaneous system commands

Replies are listed 'Best First'.
Re: Re: Creation of simultaneous system commands
by kesterkester (Hermit) on Feb 26, 2004 at 17:23 UTC
    For example:
    foreach ( @your_jobs ) { if ( $pid ) { # parent ; # do nothing } elsif ( defined $pid ) { # child # do something with $_ here, and then exit: exit; } else { die "fork failure $!"; } }

    I've just started learning about forking, but this seems to be the general way to do it.

    update: oop, that should've been foreach instead of while

      And if your jobs are external programs to be run:
      fork // die || exec $_ for @jobs;

      If they are subs to be called:

      fork // die || exit &$_ for @jobs;

      Abigail