【问题标题】:something wrong when I exec a script with perl (ubuntu10.10)当我使用 perl (ubuntu10.10) 执行脚本时出现问题
【发布时间】:2013-12-05 10:39:13
【问题描述】:

我有一个名为 test_perl.pl 的 perl 脚本并尝试执行它。
脚本的第一行是:

#!/usr/bin/perl

当我尝试执行此脚本时,出现错误。

$ type perl
perl is /usr/bin/perl

$ ll /usr/bin/perl test_perl.pl
-rwxr-xr-x 2 root        root        10352 2011-04-23 03:32 /usr/bin/perl*
-rwxr-xr-x 1 jim         jim         12121 2013-11-21 11:47 test_perl.pl*


$ test_perl.pl
test_perl.pl: line 1: #!/usr/bin/perl: No such file or directory

我不知道为什么会这样。

【问题讨论】:

    标签: perl bash ubuntu


    【解决方案1】:

    您的文件开头有一个 BOM(请参阅 http://en.wikipedia.org/wiki/Byte_order_mark)。

    试试

     xxd test_perl.pl
    

    看到它。摆脱 BOM 将修复您的脚本:很多方法可以做到这一点:Using awk to remove the Byte-order mark

    【讨论】:

      猜你喜欢
      • 2019-07-16
      • 1970-01-01
      • 2020-10-28
      • 1970-01-01
      • 2021-08-26
      • 2019-02-05
      • 2019-07-12
      • 2010-10-11
      • 2010-11-14
      相关资源
      最近更新 更多