use strict; use IO::File; use IO::Pipe; use Pod::Html qw( &pod2html ); # I only use $fh to get a pod string, It is not part # of the solution. my $fh = IO::File->new("input_record_separator( undef ); my ($str); $str = $fh->getline(); $fh->close; # Got the pod string in $str my $pipe = IO::Pipe->new() or die "failed to create pipe: $!"; my ($pid,$fd); if ( $pid = fork() ) { #parent open(TMPSTDIN, "<&STDIN") or die "failed to dup stdin to tmp: $!"; $pipe->reader(); $fd = $pipe->fileno; open(STDIN, "<&=$fd") or die "failed to dup \$fd to STDIN: $!"; pod2html(); open(STDIN, "<&TMPSTDIN") or die "failed to restore dup'ed stdin: $!"; } else { #child $pipe->writer(); $pipe->print($str); $pipe->close(); exit 0; } $pipe->close(); exit 0;