]> git.vpit.fr Git - perl/modules/IPC-MorseSignals.git/blob - samples/tryityourself.pl
Importing IPC-MorseSignals-0.06.tar.gz
[perl/modules/IPC-MorseSignals.git] / samples / tryityourself.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib qw!blib/lib!;
7
8 use IPC::MorseSignals qw/msend mrecv/;
9
10 my $pid = fork;
11 if (!defined $pid) {
12  die "fork() failed : $!";
13 } elsif ($pid == 0) {
14  my $s = mrecv local %SIG, cb => sub {
15   print STDERR "I, the child, recieved this from $_[0]: $_[1]\n";
16   exit
17  };
18  print STDERR "I'm $$ (the child), and I'm waiting for data...\n";
19  1 while 1;
20 }
21
22 print STDERR "I'm $$ (the father), and I'm gonna send a message to my child $pid.\n";
23
24 msend "This message was sent with IPC::MorseSignals" => $pid;
25 waitpid $pid, 0;