perl shebang needs -w to work???
Why???
4 Replies
I'm not a PERL developer, but my guess is that omitting -w treats warnings as errors, hence why your script won't run. But again, that's just a guess. Ideally, you'd have no warnings, and so there'd be no difference between using -w or not.
@ybop:
My perl script wouldn't work, coming up with server error until I put the "-w" on the end of the shebang. Now it works perfectly, no errors.
Why???
Can you post the exact error message for even a simple test case, please? It would be very helpful in assisting us with assisting you in figuring this out.
@ybop:
My perl script wouldn't work, coming up with server error until I put the "-w" on the end of the shebang. Now it works perfectly, no errors.
Why???
This is a guess:
You wrote the script (or transferred or it something) through a Windows machine and so you have CRLF line endings. This means your first line was really
!/usr/bin/perl^M
(with the ^M meaning a carriage-return).
Of course there is no program /usr/bin/perl^M and so the OS refused to run it.
By adding "-w" you turned it into
!/usr/bin/perl -w^M
and this ran OK (perl ignored the ^M).
If this is your problem then "dos2unix" will fix your file. You should then look into how you transfer your programs and ensure you have the correct line endings for unix (just a LF).