Your problem is that Windows prefers a different line ending convention (CRLF, or \r\n
) than other operating systems (LF, or \n
). Your editor is creating files with \r\n
line endings by default.
The shebang is parsed by the operating system, which is not as forgiving as Perl about the stray \r
at the end of the command. It tries to run /usr/bin/perl\r
, which doesn't exist.
Your text editor should be able to save the script with Unix line-endings. This won't cause problems with using it on Windows, though a few Windows text editors (including Notepad) won't recognize the line endings properly. This will make it work properly on Linux.