package PapaCat; use strict; use warnings FATAL => 'all'; use Moose; use Kitty; use FileHandle; use Data::Dumper; sub pipe_test { my $self = shift; pipe(my $fh_from, my $fh_to); $fh_to->autoflush(1); my $pid; my $obj = Kitty->new(fh_to=>$fh_to); if (!($pid = fork())) { $obj->meow(); exit(); } elsif (!defined($pid)){ #fork failed print "fail:fork retuns with error.\n"; return; } $obj->pid($pid); my $result = readline($fh_from); print $result; $obj->close(); close $fh_to; sleep(1000); # make sure the parent won't quit first } 1;