The file was created on a non-Linux system and uploaded without converting line endings, or if you created the file on your linux system, the editor was in the wrong line-ending mode. Also, isn't the message "/usr/bin/perl^M: bad interpreter: No such file or directory"? It's really important to post complete error messages, as something that might seem irrelevant to you may provide insight into problem that others who are accustomed to seeing error messages can better decipher. After all, if you understood what parts of the message were important you wouldn't need to ask, right? ;)
In this thread, "/usr/bin/perl^M: bad interpreter:", I really like the statement, "The ^M is the key to the entire problem, it's not something that just can be ignored."
What that message is really telling you is that your operating system cannot find an interpreter named /usr/bin/perl^M. Windows and DOS terminate text lines with carriage-return (ASCII 13), followed by line-feed (ASCII 10). Linux uses just line-feed to terminate lines. So the shell knows that when it sees #!/usr/bin/perl^J, where ^J is the ASCII-10 line feed at the end, that line feed character can be stripped away from the text, and it can go looking for an interpreter named /usr/bin/perl.
But in your case, your shell is finding #!/usr/bin/perl^M^J (ASCII 13, ASCII 10 at the end of line), it again gladly ignores the linefeed, but thinks that you are looking for a program named #!/usr/bin/perl^M, where "^M" represents ASCII 13, the carriage return character. It's unlikely that you have a Perl interpreter named perl^M, and since you don't, your shell complains to you.
There are utilities that can convert DOS/Windows line endings to Linux line endings. Also FTP clients, in "text" mode will handle the conversion for you silently. And some editors can be configured to generate output with linefeeds as line terminators even when edited on carriage-return/line-feed operating systems. The easiest mechanism is to just set your FTP client to do the conversions for you. ...or develop in an environment that matches your target deployment operating system.
| [reply] [d/l] [select] |
"What did I miss?"
dos2unix script.pl?
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] [d/l] |
Have you tried perl -i -pe 'y/\r//d' script.pl ? | [reply] [d/l] |
dos2unix script.pl
| [reply] [d/l] |
use strict; use warnings?
| [reply] |