Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi, i just started programming perl and already stumbled across a (to me) inexplicable problem. but see for yourself:
1 [23:34, 47deg, 54%] steppenwolf@baby:~/documents/perl$ ./print +.pl 2 bash: ./print.pl: /usr/bin/perl: bad interpreter: Permission de +nied 3 [23:34, 47deg, 54%] steppenwolf@baby:~/documents/perl$ perl pr +int.pl 4 hello world![23:34, 47deg, 54%] steppenwolf@baby:~/documents/pe +rl$ la /usr/bin/perl 5 -rwxr-xr-x 2 root root 1.1M Sep 26 12:22 /usr/bin/perl 6 [23:34, 47deg, 54%] steppenwolf@baby:~/documents/perl$ cat pri +nt.pl 7 #!/usr/bin/perl 8 9 print 'hello world!'; 10 [23:34, 47deg, 53%] steppenwolf@baby:~/documents/perl$
can anyone give me a hint on how to solve that problem? thanks, -wanja

Replies are listed 'Best First'.
Re: script-problem
by gellyfish (Monsignor) on Oct 20, 2004 at 08:49 UTC

    The #!/usr/bin/perl is either wrong for your system (the path to perl may be /usr/local/bin/perl or something else) or there is some unprintable character after the 'perl' adding a '--' after that will fix that.

    /J\

Re: script-problem
by eyepopslikeamosquito (Archbishop) on Oct 20, 2004 at 09:12 UTC

    In addition to gellyfish's excellent response, I'd like to see the output of these two commands:

    od -cx print.pl type perl

    In the od -cx output I'd expect to see \n but not \r -- is it possible the file print.pl is in DOS format?

Re: script-problem
by Anonymous Monk on Oct 20, 2004 at 09:43 UTC
    You forgot to make your script executable, as this demo shows:
    $ ls -l /usr/bin/perl -rwxr-xr-x 2 root root 2478418 Jan 16 2004 /usr/bin/perl $ rm -f print.pl $ echo '#!/usr/bin/perl' > print.pl $ echo 'print "Hello, world\n"' >> print.pl $ ls -l print.pl -rw------- 1 anonymous monk 39 Oct 20 11:33 print.pl $ ./print.pl bash: ./print.pl: /usr/bin/perl: bad interpreter: Permission denied $ chmod +x print.pl $ ls -l print.pl -rwx------ 1 anonymous monk 39 Oct 20 11:33 print.pl $ ./print.pl Hello, world
    It's not that your she bang line is wrong as a previous poster suggested. If that was the case, you would get the message:
    $ bash: ./print.pl: /usr/bin/perl: bad interpreter: No such file o +r directory
    which you would also get if there were "unreadable" characters after 'perl' as the other posted suggested.
      hi guys, thanks for your very quick (!) help! unfortunately, neither one helped me get rid of my problem. here is some more output as requested:
      [12:28, 36deg, 31%] steppenwolf@baby:~/documents/perl$ la print.pl -rwxr-xr-x 1 steppenwolf steppenwolf 39 Oct 20 12:26 print.pl [12:28, 36deg, 31%] steppenwolf@baby:~/documents/perl$ which perl /usr/bin/perl [12:28, 36deg, 31%] steppenwolf@baby:~/documents/perl$ type perl perl is /usr/bin/perl [12:28, 36deg, 31%] steppenwolf@baby:~/documents/perl$ od -cx print.p +l 0000000 # ! / u s r / b i n / p e r l \ +n 2123 752f 7273 622f 6e69 702f 7265 0a6c 0000020 \n p r i n t ' h e l l o w +o 700a 6972 746e 2720 6568 6c6c 206f 6f77 0000040 r l d ! ' ; \n \0 6c72 2164 3b27 000a 0000047 [12:28, 36deg, 31%] steppenwolf@baby:~/documents/perl$
      does that help you?