简体   繁体   English

Perl拒绝运行脚本

[英]Perl refuses to run scripts

I'm using Perl 5.14.2 on Cygwin, and suddenly it refuses to run the simplest of scripts: 我在Cygwin上使用Perl 5.14.2,突然它拒绝运行最简单的脚本:

#!/usr/bin/perl
use strict;
use warnings;
print "hello world!\n";

Trying to execute this causes Perl to do absolutely nothing, and neither does $? 尝试执行此操作将导致Perl绝对不执行任何操作,并且$?也不会执行$? contain anything: 包含任何内容:

Administrator@Windows7 /cygdrive/d/Development/Perl
$ perl helloworld.plx

Administrator@Windows7 /cygdrive/d/Development/Perl
$ echo $?
0

However, I have written more complex scripts earlier, and they do run: 但是,我之前编写了更复杂的脚本,并且它们确实可以运行:

Administrator@Windows7 /cygdrive/d/Development/Perl
$ perl siteinfo.plx

Site info : google.com
________________________________________________________________________________
Whois : ( ... whois info printed here ...)
hpHosts : Not Listed

I really can't understand what is exactly going on here. 我真的不明白这里到底发生了什么。 I've tried reinstalling Perl but with no luck. 我试过重新安装Perl,但是没有运气。

Any help is deeply appreciated. 任何帮助深表感谢。

The answer to this turns out to be very dumb: 答案很愚蠢:

My text editor was set to churn out text files with Macintosh EOL format. 我的文本编辑器被设置为生产Macintosh EOL格式的文本文件。 Converting it to Unix/Windows format corrects the issue. 将其转换为Unix / Windows格式可解决此问题。

However, one thing that I found strange was that Perl would not notify of this issue, and instead it simply did nothing. 但是,我感到奇怪的一件事是Perl不会通知该问题,相反它什么也没做。

Use B::Deparse to see how perl parses your program 使用B :: Deparse查看perl如何解析您的程序

  $ perl -MO=Deparse,-p -e ""
  -e syntax OK

  $ perl -MO=Deparse,-p -e "#!/usr/bin/perl -- die 666; "
  -e syntax OK

  $ perl -MO=Deparse,-p -e "die 666; "
  die(666);
  -e syntax OK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM