in reply to Re: NET::FTP ASCII mode not translating end-of-lines
in thread NET::FTP ASCII mode not translating end-of-lines
I tried fetching/putting a windows-style text file (between a solaris server and my local linux box) using ascii mode with both Net::FTP and the command-line ftp utility. They both preserved the "\r\n" line terminations in the text file.This is the expected behavior. The sending system in an FTP ASCII transfer takes whatever the local notion of a line is and sends it as a series of characters terminated with CR-LF "\r\n". So if you are sending from a Unix system, a file that starts of "abc\ndef\r\nghi\n" will be sent as "abc\r\ndef\r\r\nghi\r\n". Any \r that is already in the text file is treated as just another character.I noticed that the alleged "ascii" mode transfer actually causes more bytes to be transmitted -- a remote file with 20162 bytes (including 278 \r's and 279 \n's) reports 20441 bytes sent, whereas a binary transfer reports exactly 20162 bytes. Alas, both methods leave me with a 20162-byte file (i.e. no difference in the local copy). Anyway, it might not be the fault of the perl module.
The receiving system in an FTP ASCII transfer translates the CR-LF pairs back to whatever the local notion of a line is. So on another Unix system, you'll get back the original file.
On Windows, though, it's different. A file that starts "abc\r\ndef\r\n" will be sent just like that in ASCII mode. A receiving Unix FTP process (in ASCII mode) will convert it to "abc\ndef\n".
As I said above, if he is running Cygwin Perl instead of ActivePerl, and the file is on a binmode mount, then the file will be treated just like a Unix file.
|
|---|