You've run across the typical cross-platform issues that arise between Unix
and Windows.  The problem is that Windows uses \r\n to terminate a line
while Unix just uses \n.  When perl on unix sees \r it doesn't know what to
do because it only expects \n.  Therefore, to correct the problem, you need
to change all \r\n to just \n.  A typical way to do this is to run dos2unix
on the file.  However, not all systems come with dos2unix.  Therefore, you
can run

perl -e "while( <> ) { s/\r\n/\n/g; print; }" infile.txt > outfile.txt

and have it remove the extraneous \r characters from  infile.txt and have it
written to outfile.txt

Thanks!
Tanton
----- Original Message -----
From: "Student of Perl" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 06, 2002 5:18 AM
Subject: Illegal character error for blank line.


>
> Hi there,
>
> i have very strange problem.
> I have a simple script which I run
> on Windows98 (PC) and it
> executed properly. But when I
> sent it to someboday by email
> who uses Unix ; it give error.
>
>
> The first 3 lines of the script are
> comments in following format.
>
> # comment1
> # comment2
> # comment3 ..
>
> "the script starts here"
>
> the two dots after 3rd comments are AS IT IS in
> the script. After the 3rd line ; there is one blank
> line. And after that blank line the sctual script
> starts. So the error given by Perl is that
>
> "Illegal character \015 (carriage return) at sample.pl line 4."
>
> In fact the line number 4 is blank(and yes it is carriage
> return). But then why should it give error? By the way
> sample.pl is the name of the script file. The script runs
> properly on my Windows98 but gives above error on
> Unix machine. By the way on my Windows98 machine
> I use ActivePerl ; I dont know about what Perl interpreter
> is used on that remote Unix machine. But anyway I
> am surprised to see that just because I left a blank line
> the Perl should give error? On the contrary Perl is said
> to be quite flexible and forgiving language. And also
> I have never come across such an error before myself.
> Also the "#" is the first character in all the 3 comments
>
> Pls answer. Its very confusing situation. Once again ;
> I have Win98 and using ActivePerl of ActiveState.
> I typed my script in simple DOS editor.
> Thanks
> -Jim
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to