How can I translate a shell script to Perl?

前端 未结 6 1927
长情又很酷
长情又很酷 2021-01-30 15:31

I have a shell script, pretty big one. Now my boss says I must rewrite it in Perl. Is there any way to write a Perl script and use the existing shell code as is in my Perl scrip

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 15:43

    You could start your "Perl" script with:

    #!/bin/bash
    

    Then, assuming bash was installed at that location, perl would automatically invoke the bash interpretor to run it.

    Edit: Or maybe the OS would intercept the call and stop it getting to Perl. I'm finding it hard to track down the documentation on how this actually works. Comments to documentation would be welcomed.

提交回复
热议问题