use strict; my $pid = open my $pipe, "-|"; die "Can't fork: $!\n" if ! defined $pid; if( ! $pid ) { my $output = eval ...; print $output; exit; } local $/; my $output = <$pipe>; close $pipe;