相关疑难解决方法(0)

为什么shebang线总是第一线呢?

我有简单的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应该总是在顶部无论如何.但有人能解释我为什么吗?

unix perl solaris shebang

20
推荐指数
3
解决办法
1万
查看次数

标签 统计

perl ×1

shebang ×1

solaris ×1

unix ×1