in reply to Problem with running Perl script on Mac OSX

Sounds like a line-ending problem. Try looking at the script with cat -vET.

If there's a Windows-style line end on a file, Unix will often misinterpret the "shebang" line saying where to find the interpreter as /usr/bin/perl^M, and since there isn't a program called /usr/bin/perl^M it fails. By editing that line, you may have fixed the line ending, accidentally fixing the problem.

If that's the problem, tools like dos2unix can fix it, or something like:

perl -pi.bak -e 's/\r//g' your_script

Replies are listed 'Best First'.
Re^2: Problem with running Perl script on Mac OSX
by dracos (Sexton) on May 31, 2006 at 16:23 UTC
    Actualy I can spend all day editing it back and forth adding and removing the "-w" or even "-d" and if there is nothing after the #!/usr/bin/perl it fails.. But I will double check it when I get home and make sure that I have run dos2unix on it.

    The real confusion is it works fine on Fedora Core 5 even with the "^M" in it.