• [^] # Re: Hello World concurrentiel

    Posté par (courriel, site web personnel) . En réponse à la dépêche De tout, de rien, des bookmarks, du bla‐bla #45. Évalué à 6.

    #!/usr/bin/perl -w
    use strict;
    use feature 'say';
    use IO::Handle;
    $|++;
    pipe HELLOR, HELLOW;
    pipe WORLDR, WORLDW;
    HELLOW->autoflush(1);
    WORLDW->autoflush(1);
    my $worldpid;
    if ($worldpid = fork) {
     for (1..1000) {
     print "Hello, ";
     say WORLDW "PING";
     <HELLOR>;
     }
     say WORLDW "DIE";
    } else {
     while (<WORLDR>) {
     last if /DIE/;
     say "World!";
     say HELLOW "PONG";
     }
    }
    
    

    pertinent adj. Approprié : qui se rapporte exactement à ce dont il est question.