How to call a python script from Perl?

前端 未结 4 1069
逝去的感伤
逝去的感伤 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

    Francisco's cool response:

    my $ret = `/usr/bin/pdf2txt.py arg1 arg2 2>&1`;
    

    is simplified by Blagovest Buyukliev:

    my $ret = `/usr/bin/pdf2txt.py arg1 arg2`;
    

    The alternative is,

    my $ret = system(/usr/bin/pdf2txt.py arg1 arg2`);
    

    I don't think will work because the output is printed onto the screen and will not be captured by $ret

提交回复
热议问题