At the first, you can't write HTTP::Response into the stream directly. The error mean the string that written as "HTTP::Response..." haven't method decoded_content
.
You must write string got from decoded_content, and read as the string.
use LWP::UserAgent;
use IO::Handle;
use Encode;
pipe my $ua_reader, my $ua_writer;
my $url = "http://some-sample-html-file";
my $ua = LWP::UserAgent->new;
$ua->timeout(1);
my $ua_process = fork();
if( $ua_process == 0 ) {
close $ua_reader;
print $ua_writer encode_utf8 $ua->get($url)->decoded_content;
exit 0;
}
do {
$ua_process = waitpid(-1, 1);
} while ($ua_process != 0);
close $ua_writer;
my $response = $ua_reader->getline;
close $ua_reader;
print $response;