![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Convert binary to ascii while sftp using Net::SSH2by 0xbeef (Hermit) |
on Mar 01, 2011 at 20:34 UTC ( #890812=note: print w/replies, xml ) | Need Help?? |
The problem is that you are transferring a text file between systems that differ in how they represent an end of line character. This is precisely the reason why a program such as FTP implement the bin and ascii mode functions. When you transfer a file in binary mode, it remains unchanged (this mode is typically used to transfer compiled programs / BINaries). When dealing with end of line characters in text files that roboticus elaborated on, ascii mode would have to be used to do a transformation of the end of line character to make it appropriate to the target platform. In perl, you would need to use a s/\r\n/\n/; to do the equivalent transform when doing a Windows -> UNIX transfer. The reason for this madness lies in how early computer systems had to interact with teletype and typewriter devices that were unable to advance the print head to the next line in single character time (see Newline).
In Section
Seekers of Perl Wisdom
|
|