简体   繁体   中英

Perl refuses to run scripts

I'm using Perl 5.14.2 on Cygwin, and suddenly it refuses to run the simplest of scripts:

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

Trying to execute this causes Perl to do absolutely nothing, and neither does $? 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.

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. Converting it to Unix/Windows format corrects the issue.

However, one thing that I found strange was that Perl would not notify of this issue, and instead it simply did nothing.

Use B::Deparse to see how perl parses your program

  $ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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