$ cat -n openself 1 #!/usr/local/bin/perl -w 2 use strict; 3 use utf8; 4 binmode(STDOUT, ':utf8'); 5 binmode(STDIN, ':utf8'); 6 7 print "Father: $$\n"; 8 9 my $pid = open(STDOUT, "|-"); 10 die "cannot fork: $!" unless defined $pid; 11 12 # Child filters father's output 13 filterstdout() unless $pid; 14 15 # Father 16 print " <- This is the PID of the child\n"; 17 while (<>) { 18 print 19 } 20 21 sub filterstdout { 22 while () { 23 tr/αινσϊρ€/aeioun$/; 24 print "$$: $_"; 25 } 26 exit; 27 }