我只是写了一些测试python代码到test.py,我推出它如下:
perl test.py
过了一会儿,我意识到了我的错误。我说“过一会儿”,因为
Python代码实际上正确执行,就像在Python解释器!
为什么我的Perl解释我的Python? test.py看起来像这样:
#!/usr/bin/python ...Python code here...
解决方法
从
perlrun,
If the
#!
line does not contain the word “perl” nor the word “indir” the program named after the#!
is executed instead of the Perl interpreter. This is slightly bizarre,but it helps people on machines that don’t do#!
,because they can tell a program that their SHELL is /usr/bin/perl,and Perl will then dispatch the program to the correct interpreter for them.
例如,
$ cat >a #!/bin/cat meow $ perl a #!/bin/cat meow