How to call a python script from Perl?

前端 未结 4 1059
逝去的感伤
逝去的感伤 2020-12-14 10:09

I need to call \"/usr/bin/pdf2txt.py\" with few arguments from my Perl script. How should i do this ?

4条回答
  •  感情败类
    2020-12-14 10:26

    If you don't need the script output, but you want the return code, use system():

    ...
    my $bin = "/usr/bin/pdf2txt.py";
    my @args = qw(arg1 arg2 arg3);
    my $cmd = "$bin ".join(" ", @args);
    
    system ($cmd) == 0 or die "command was unable to run to completion:\n$cmd\n";
    

提交回复
热议问题