Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: (OT) Fixing Line Endings

by davorg (Chancellor)
on Nov 30, 2006 at 14:52 UTC ( #586952=note: print w/replies, xml ) Need Help??

in reply to Re: (OT) Fixing Line Endings
in thread (OT) Fixing Line Endings

A Perl program that is created on Windows will have Windows line end characters (i.e. CR/LR or \015\012). If you upload that to a Unix server without translating the line endings then your shebang line will look like this:


The \n is the line end character for Unix, so that's not a problem. But some Unix shells will look for a program called /usr/bin/perl\r and, usually, won't find it.

As a couple of us have suggested, adding an option to the shebang line solves the problem as the shebang line will then look like this:

#!/usr/bin/perl -w\r\n

The shell parses the command name (/usr/bin/perl) out of that and passes the rest of it (-w\r) to the Perl interpreter as options. Perl is cleverer than the shell and will handle both kinds of line endings.


"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^3: (OT) Fixing Line Endings
by jgamble (Pilgrim) on Dec 01, 2006 at 16:31 UTC

    A Perl program that is created on Windows will have Windows line end characters (i.e. CR/LR or \015\012).

    Although, just for informational purposes, it's important to note that you don't have to create files with the \r\n ending. I've been creating all of my files with \n endings for years on Windows, and it's saved me a lot of grief, particularly when ftp-ing files without worrying about setting text mode. The text editors that I've been using are jedit and vim; I'm sure there are others that can do this.

Re^3: (OT) Fixing Line Endings
by sgt (Deacon) on Dec 01, 2006 at 22:24 UTC

    actually she-bang is a kernel thing you have to fix the broken kernel ...which I would not call un*x


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://586952]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2021-05-08 08:37 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (96 votes). Check out past polls.