open my $fh, "pdftohtml -noframes -stdout $pdf |" or die "Can't run pdftohtml: $!"; while (<$fh>) { &func($_); } close($fh);