use strict; use warnings; my $cmd = qq(pdftotext "a.pdf" - |); my $pid = open (FILE, $cmd) or die "Couldn't spawn [$cmd]: $! / $?"; print my $text = do { local($/); }; close FILE;