How does Perl handle DOS newlines? 
Author Message
 How does Perl handle DOS newlines?

'scuse me if this has been answered before, but I don't normally
worry 'bout DOS...

Someone using Perl on a DOS machine has asked me some questions, and
it's not clear to me how Perl for DOS handles newlines, as they are
CR-LF combinations.  Does \n match the pair?

--

    /  ) /       |------------------------------------------------------
   /__/ /_   __  |
  /  / /  ) /__) |   "It ain't watcha do, it's the way how ya do it."



Tue, 29 Aug 1995 04:44:05 GMT  
 How does Perl handle DOS newlines?

Quote:

>'scuse me if this has been answered before, but I don't normally
>worry 'bout DOS...
>Someone using Perl on a DOS machine has asked me some questions, and
>it's not clear to me how Perl for DOS handles newlines, as they are
>CR-LF combinations.  Does \n match the pair?

All of the DOS perl ports I have look at handle this in the same way.
The default mode that file are opened in is called TEXT mode, in this
mode the \r\n pair is converted to \n on input and \n is converted to
\r\n on output.  DOS perl adds a special call binary(FILEHANDLE) that is
used after open but before the first read or write to specify that the
file is to be read or written unconverted.  These file mode are basically
just those provided by the C compilers stdio implementation (both
Microsoft and Borlkand turbo C provide for TEXT vs BINARY modes).
See the README file that should have accompanied your DOS perl executable.

--
Perl's Maternal Uncle
Mark Biggar



Tue, 29 Aug 1995 06:51:25 GMT  
 How does Perl handle DOS newlines?


) Subject: Re: How does Perl handle DOS newlines?
) Organization: L{*filter*}Western Development Labs
) Date: Thu, 11 Mar 93 14:51:25 PST
)

) >'scuse me if this has been answered before, but I don't normally
) >worry 'bout DOS...
) >Someone using Perl on a DOS machine has asked me some questions, and
) >it's not clear to me how Perl for DOS handles newlines, as they are
) >CR-LF combinations.  Does \n match the pair?
)
) All of the DOS perl ports I have look at handle this in the same way.
) The default mode that file are opened in is called TEXT mode, in this
) mode the \r\n pair is converted to \n on input and \n is converted to
) \r\n on output.  DOS perl adds a special call binary(FILEHANDLE) that is
) used after open but before the first read or write to specify that the
) file is to be read or written unconverted.  These file mode are basically
) just those provided by the C compilers stdio implementation (both
) Microsoft and Borlkand turbo C provide for TEXT vs BINARY modes).
) See the README file that should have accompanied your DOS perl executable.
)

Actually, I believe that the function is called binmode, and it is a
standard function of PERL.  It has no effect on machines where text
and binary mode are the same.

Once a file is converted to binary mode, there is no going back.

Also, I think that stdin and stdout can not by converted to binmode.

--



Tue, 29 Aug 1995 09:33:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Perl source with DOS newlines on unix

2. How to use newlines in DOS command options

3. dos & newline

4. How to handle escaped newlines????

5. Handling DOS EOF with Perl?

6. Handling DOS EOF with Perl?

7. Doing port to DOS 386 protected mode.

8. Replacing multiple occurences of newline chars with a single newline char

9. (DOS) Handling records with linefeeds?

10. Perl 4.036 for DOS and the DOS Environment

11. Perl 4.0 PL10 for DOS, DOS-Extender and OS/2

12. Perl Tutorial Book (was Re: SED GURUS: Some Newline Questions)

 

 
Powered by phpBB® Forum Software