in reply to Perl Directive

There is also the obscure benefit of protecting yourself slightly from lineending difficulties: if you write your script on a machine with DOS newlines, and move it to unix in binary mode, you might get an annoying error such as:

./myscript.pl: Command not found.

This is because the first line is something like: #!/usr/bin/perl^M

("Something like" meaning perhaps you assumed your perl was in another path.) The command that isn't found is perl^M, but the shell's error message can be infuriatingly misleading. At least the first few times your run into it. If you instead get into the habit of always turning on warnings from the shebang line, #!/usr/bin/perl -w^M

...then the OS kernel loads #!/usr/bin/perl correcty, and perl itself is smart enough to do the right thing about subsequent DOS lineendings. Also, you get warnings turned on :)

Replies are listed 'Best First'.
Re^2: Perl Directive
by blahblahblah (Priest) on Dec 13, 2004 at 16:43 UTC
    Good point.

    If you don't want to specify -w on the shebang line, you can get the same effect with "--":

    #!/usr/bin/perl --^M