Andy Wardley wrote:
> I'm at a loss.  This script works fine:
> 
>    #!/usr/bin/perl -w
>    print "good\n";
> 
> and this script is broken:
> 
>   #!/usr/bin/perl
>   print "bad\n";
> 
> I can run the first as './good.pl' but if I run the second as 
> './bad.pl' I get:
> 
>   bash: ./bad.pl: bad interpreter: No such file or directory

My guess: this file was transferred in text mode from a DOS type system.
Therefore, bash complains in the second case that it can't find a file
called "/usr/bin/perl^M", while in the first case it finds "/usr/bin/perl"
and calls it with arguments "-w^M scriptname", and since perl handles
CRLF-terminated lines correctly in newer revisions (IIRC), that works out
fine.

Yet another reason to always use -w :) (even if it's been a bit superseded
by "use warnings").

IOW, check your first line with "head -1 bad.pl | od" or something like that
and see whether there are any naughty characters in it.

Cheers,
Philip
[email copies are appreciated, since I read the digest]
-- 
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.

Reply via email to