Search code examples
bashshellperlscriptingcmusphinx

perl <file.pl> gets executed with no output at all


I downloaded a perl script (http://www.speech.cs.cmu.edu/tools/download/quick_lm.pl) for generating language models.

When I do perl quick_lm.pl, it simply terminates. No output at all.

  • Yes, I have perl installed and perl -v works perfectly.

  • I made a simple hello-world perl script and it executes just fine. [attached at the end]

  • So, I included print "hello"; in the first line of the quick_lm.pl and tried perl quick_lm.pl, still nothing happens.

I even tried giving the quick_lm.pl all permissions using chmod 777 quick_lm.pl. Now when I do ./quick_lm.pl it gives an error :

-bash: ./quick_lm.pl: /usr/local/bin/perl: bad interpreter: No such file or directory

I searched this error and almost all the solutions pointed to windows CLRF, but unlike them I do not have ^M in /usr/local/bin/perl. Also, still perl quick_lm.pl should work, right?


[bash.log]

someone@something:~/dictionary$ perl quick_lm.pl
someone@something:~/dictionary$ perl quick_lm.pl -s words.txt 
someone@something:~/dictionary$ nano quick_lm.pl 
someone@something:~/dictionary$ perl quick_lm.pl -s words.txt 
someone@something:~/dictionary$ chmod 777 quick_lm.pl 
someone@something:~/dictionary$ ./quick_lm.pl 
-bash: ./quick_lm.pl: /usr/local/bin/perl: bad interpreter: No such file or directory
someone@something:~/dictionary$ cat new.pl 
#!/usr/bin/perl -w 
use strict;

print "Hello World\n";
someone@something:~/dictionary$ perl new.pl 
Hello World
someone@something:~/dictionary$ 

[After adding print in the beginning of quick_lm.pl and reducing it to a minimal, runable demonstration of the problem.]

#!/usr/local/bin/perl -w
=POD

...license...

=END

use Getopt::Std;

print "hello world";
$VERBOSE = 1;

sub handler { local($sig) = @_;
          print STDERR "quick_lm caught a SIG$sig -- dying\n";

          exit(0);
        }
foreach (qw(XCPU KILL TERM STOP)) { $SIG{$_} = \&handler; }

This is not full script, full script is in the link mentioned in the very first line. I am not sure if it's related to file as much as my perl configuration. As you might have guessed, I don't have much idea about perl.

I appreciate your time and help :)


Solution

  • -bash: ./quick_lm.pl: /usr/local/bin/perl: bad interpreter: No such file or directory

    Replace /usr/local/bin/perl with the correct path to perl. This path can be obtained from

    perl -le'print $^X'
    

    it simply terminates. No output at all.

    The =pod directive indicates the start of inlined documentation ("POD"). =cut marks the end of the block of POD.

    The program incorrectly uses =END instead of =cut to mark the end of the block of POD, so Perl thinks the whole program is one big comment.. Replace =END with =cut.