in reply to how to solve producer consumer problem in perl when threads are disabled
#!/usr/bin/perl # code by pg use IO::Handle; use strict; use warnings; $| ++; pipe(PARENT_RDR, CHILD_WTR); if (fork()) { if (fork()) { close CHILD_WTR; while (my $line = <PARENT_RDR>) { print "parent got $line"; } } else { close PARENT_RDR; for (100..110) { print CHILD_WTR "$_\n"; } } } else { close PARENT_RDR; for (0..10) { print CHILD_WTR "$_\n"; } }
|
|---|