in reply to Comments trouble

Try putting as the first line of your script:

#!/usr/bin/perl

A comment as the very first line of the script is sometimes used by your OS and/or by Perl to determine what interpreter to run. Normally it has to start with #!, but it's possible something weird is going on. And besides, starting off your script with a proper "shebang" line is good form. :-)

If that doesn't work, show us the output, inside <code> tags, of cat -e yourscript, or whatever the equivalent is on MacOS X. That should show any nonprinting characters, and mark the ends of lines.