Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Net::FTP and corrupted uploads

by monarch (Priest)
on Jun 06, 2008 at 17:57 UTC ( [id://690723]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP and corrupted uploads

At first guess I'd say Net::FTP could be using chomp?

Let's say, you're on a Win32 machine, chomp is designed to remove the last 2 characters (CR,LF) right? Then say you feed a unix-formatted file through, then it is conceivable that chomp does the "wrong thing" and takes the last character of text from each line as well as the LF.

Personally I never use chomp. Instead I prefer to correct for line endings by doing the following:

$line =~ s/(\r\n|\n\r|\r|\n)//;

The regular expression forces a test for CR,LF and vice-versa before considering that the line may end with just a single LF. Portable across operating systems and text file formats.

It seems in this situation you are safest with just sending in binary format, and failing that maybe try hacking the source of Net::FTP yourself?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://690723]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found