我有简单的perl脚本如下:
#!/usr/bin/perl
use strict;
use warnings;
print "hello world!\n";
Run Code Online (Sandbox Code Playgroud)
我可以执行如下脚本:
>temp.pl
hello world!
>
Run Code Online (Sandbox Code Playgroud)
如果我添加这样的评论:
#this script is just for test
#the shebang
#!/usr/bin/perl
use strict;
use warnings;
print "hello world!\n";
Run Code Online (Sandbox Code Playgroud)
当我尝试执行时,它给我输出如下:
> temp.pl
use: Command not found.
use: Command not found.
print: Command not found.
>
Run Code Online (Sandbox Code Playgroud)
这里的重点是shebang line应该总是在顶部无论如何.但有人能解释我为什么吗?