use PHP; my $php_file = '/path/to/file.php'; open my $fh,'<',$php_file or die $!; my $content = do{local $/;<$fh>}; close $fh; my $return; PHP::options( stdout => sub {$return = $_[0];}); PHP::eval($content);