|Just another Perl shrine|
Re: perl and linuxby mandog (Curate)
|on Oct 26, 2003 at 19:47 UTC||Need Help??|
A couple other things you might consider:
The shbaing line tells Linux and your shell where to find perl so it can run your script. Somethingn like this:'#!/usr/bin/perl -w '
...as the very first line of your script. Don't include the quotes, but do include the space after the -w
The -w and the space are not strictly necessary but they are useful.
The -w will give you helpful extra error messages. For more details see: perldoc perlrun
The space will help prevent problems FTPing files from a MS WIndows machine to a UNIX machine. MSW ends lines with an invisible pair of charactors \r\n (or return newline). Unix doesn't see a \r as very special. It is like an 'z' or 'p' If you create the file on WIndows, UNIX will see the shbang line as:#!/usr/bin/perl -w\r
give you an error message and refuse to run. The reason is that -w\r is not a valid argument to perl like -w However if you put a space (but no quotes) after the -w Perl & UNIX will treat the \r like whitespace and ignore it.
You might not want to put the '.' into your path to avoid other peoples evil programs. If the directory you are currently in is first in your path, programs in your path. Suppose you do this:
suppose your friend has a script like this:
You may be better off running programs in the current directory explicitly:./myscript.pl