If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Welcome to Mac-Forums! Join us to comment and to customize your site experience! Members have access to different forum appearance options, and many more functions.

I can't get Perl scripts in my path to properly run under Mac OS X (10.5.2). I'm using Smultron to edit the files, and have also taken them into nano via Terminal and saved both as DOS and Mac formats. When I save as DOS, I get this when I run the file:

/usr/bin/perl^M: bad interpreter: No such file or directory

I assume it's having problem interpreting the DOS CR/LF character and shows "^M" as a result. When I save in "Mac" format, the script does nothing (not even an error) when I run it. If I cat the Mac formatted script, it doesn't display properly:

$ cat perlscript.pl
$ FG,SWITCHCFG); shutports/ig) {(.+)/ig) {

(You're seeing a tiny portion of the script there; not even the end of it - but that's all it shows.) If I save in the DOS format, I can workaround the problem by running it as "perl path/scriptname.pl"; this eliminates the misinterpretation of !#user/bin/perl^M above. What am I doing wrong? Can I not run perl scripts that are in my path without typing the longhand "perl pathlist/filename"? Thanks.

Yes, I tried using Unix LF in Smultron and it's working. Curious about nano, though. It defaults to "mac" format; can one not edit Perl scripts in nano (without using DOS format and running it longhand?)?

Ahhh... that makes sense. The files I'm working with were created on a DOS/Windows system and copied to my new Mac. Nano must've maintained the existing DOS LFs, and only offered Mac as the other format. (Converting it to a native, or Unix, format was not an option I saw within nano.) I'd probably be OK working with new files or files that Smultron has saved already with Unix LF. Thanks.