"be consistent" | |
PerlMonks |
Re: Odd -w behavior on scripts written on Win32 platformby dmmiller2k (Chaplain) |
on Jan 03, 2002 at 02:01 UTC ( [id://135814]=note: print w/replies, xml ) | Need Help?? |
Follow Ovid's advice and strip CR's from the file (perhaps even automatically, by doing an ASCII instead of BINARY transfer with FTP). The problem is that the shell expects the shebang line to be terminated with just a newline ('\n'), which it strips off (along with the initial '#!') and then tries to exec what's left. In your case, since the lines are all terminated with CR-LF ('\r\n'), stripping off the newline still leaves a CR at the end of whatever command you have there (i.e., '/usr/bin/perl\r'). By adding the '-w' switch (or *any* valid Perl option, I suspect), you will have changed the command to '/usr/bin/perl -w\r'. In other words, the '\r' is still there, but it is no longer adjacent to the command name, so the shell's shebang handler passes it to the invoked command as an argument(Perl in this case). Perl views the option string '-w\r' the same as if it were the two separate options, '-w' and '-\r'. Since you mention no warning message (when you use -w), I suppose Perl is choosing to ignore the latter, perhaps because it is a form of whitespace. Update: Perhaps I forgot to mention this, but if the shell cannot find the command specified on the shebang line, of say 'scriptname.pl', it will report the error with the message,
as shown in the original note, 'Odd -w behavior on scripts written on Win32 platform'. What this message means is more like "got a 'No such file or directory' error while trying to execute the file, './scriptname.pl'." The reason it cannot find it, of course, is that there is no binary executable file named '/usr/bin/perl\r (note the a CR character).' dmm You can give a man a fish and feed him for a day ...Or, you can teach him to fish and feed him for a lifetime
In Section
Seekers of Perl Wisdom
|
|