tie *STDOUT, TrapClass; my $pid = fork(); die "" if !defined $pid; exit 0 if $pid; # parent exits exec "/bin/date"; # child prints to STDOUT!! package TrapClass; sub TIEHANDLE { my $class = shift; open(my $fh, ">out") or die; bless { fh => $fh }, $class; } sub PRINT { my $self = shift; my $fh = $self->{fh}; print $fh @_; }