CR/LF Text-File 
Author Message
 CR/LF Text-File

Hello *.*

I want to read a string from a Text-File.
Sure, no problem.
But every string in the TEXT-file ends width a
CR/LF. (yes, it's a dos-text-file).
But the perl/skript runs on a LinuX-System.
How can i read strings from a text-file with cr/lf at the end of each
line on a LinuX-Plattform ???

Thanx...

--
MfG Tobias Poppe - Informatik HQ Karlsruhe




Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File

Re: CR/LF Text-File, Tobias

Tobias> But the perl/skript runs on a LinuX-System.  How can
Tobias> i read strings from a text-file with cr/lf at the
Tobias> end of each line on a LinuX-Plattform ???

Do this to the input line

    s/\r$//;

That will remove the CR (\r) if there's one at the end.

hth,
tony



Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File

: Re: CR/LF Text-File, Tobias

: Tobias> But the perl/skript runs on a LinuX-System.  How can
: Tobias> i read strings from a text-file with cr/lf at the
: Tobias> end of each line on a LinuX-Plattform ???

: Do this to the input line

:     s/\r$//;

: That will remove the CR (\r) if there's one at the end.

Or, better yet, when transfering the files, use FTP in ASCII mode and
it will convert the line endings for you.

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File

Quote:


> : Re: CR/LF Text-File, Tobias

> : Tobias> But the perl/skript runs on a LinuX-System.  How can
> : Tobias> i read strings from a text-file with cr/lf at the
> : Tobias> end of each line on a LinuX-Plattform ???

> : Do this to the input line

> :     s/\r$//;

> : That will remove the CR (\r) if there's one at the end.

> Or, better yet, when transfering the files, use FTP in ASCII mode and
> it will convert the line endings for you.

Why not

$/="\r\n";  #or whatever the hex values of \r\n is

--
John Moreno



Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File


Quote:
>I want to read a string from a Text-File.
>But every string in the TEXT-file ends width a
>CR/LF. (yes, it's a dos-text-file).
>But the perl/skript runs on a LinuX-System.
>How can i read strings from a text-file with cr/lf at the end of each
>line on a LinuX-Plattform ???

if you don't want to change the file, you can change the input
record separator, $/, to "\r\n".  now perl thinks a "line" ends with
"\r\n" rather than the default "\n".

if you are making a similar file on the linux box, you might want to
play with the output record separator so that "lines" end with "\r\n"
as well.

or you could just ftp everythign as ascii.

good luck :)

--

NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>



Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File


Quote:

>: Re: CR/LF Text-File, Tobias

>: Tobias> But the perl/skript runs on a LinuX-System.  How can
>: Tobias> i read strings from a text-file with cr/lf at the
>: Tobias> end of each line on a LinuX-Plattform ???

>: Do this to the input line

>:     s/\r$//;

>: That will remove the CR (\r) if there's one at the end.

>Or, better yet, when transfering the files, use FTP in ASCII mode and
>it will convert the line endings for you.

Or just set   $/ = "\r\n"   when handling such files.
--

Quote:
>> Stonehenge Consulting Services:  Perl training  (503) 777-0095 <<

       "Aarrrr!  Six{*filter*} men on a dead Dodge Dart!"  // MST3K


Sat, 03 Jun 2000 03:00:00 GMT  
 CR/LF Text-File



: > : Re: CR/LF Text-File, Tobias

: >
: > : Tobias> But the perl/skript runs on a LinuX-System.  How can
: > : Tobias> i read strings from a text-file with cr/lf at the
: > : Tobias> end of each line on a LinuX-Plattform ???
: >
: > : Do this to the input line
: >
: > :     s/\r$//;
: >
: > : That will remove the CR (\r) if there's one at the end.
: >
: >
: > Or, better yet, when transfering the files, use FTP in ASCII mode and
: > it will convert the line endings for you.

: Why not

: $/="\r\n";  #or whatever the hex values of \r\n is

Because I didn't read the question very carefully, that's why not ;-)

That will work for data.

But I don't want to exercise my feeble grey matter each time I
transfer a file.

Now is this a script file or a text data file?
Am I going from Unix to DOS or from DOS to Unix?

If I just use ASCII mode, I don't have to worry about any of that.

So I just use ASCII mode  ;-)

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Sat, 03 Jun 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Converting LF to CR+LF

2. DOS Perl convering LF to CR/LF

3. <FILE> and CR-LF

4. unwanted CR/LF translation in FILE UPLOAD

5. $/ = CR LF?

6. Binary data and CR-LF's in MSDOS

7. CR before login or any help that would lf before login

8. CR/LF

9. how to remove cr/lf ???

10. Question about formatting/(CR/LF) in PERL

11. Perl and CR+LF

12. Any Utility in Win32/Win95/Dos to remove CR or LF

 

 
Powered by phpBB® Forum Software