in reply to Fetching files (downloading) from the Internet (extra characters, file handles, file::fetch)
If you're on Windows or another OS with line-ending translation for text files, use binmode on non-text files. Writing binary files in text mode on OSes that discern between them is an easy and common mistake and it is easily fixed.
Alternately, it could be your handling of the HTTP protocol. The HTTP protocol (as with most other text-based application-level Internet protocols) specifies line endings in ASCII linefeed/carriage-return pairs for the protocol elements themselves. Certain media types also use this, although that varies based on the media type of the body. The authors of modules for Perl to deal with these things such as LWP, LWP::Simple, and WWW::Mechanize know this and handle it in their code. See RFC 1945 section 2 paragraph 2. HTML is one media type that wants cr/lf.
If you're going to roll your own solution for standardized protocols, you're going to have to do your own standards research besides your own coding and testing. If you still want to roll your own, that's great. If not, use what's provided. Either is a valid decision, but you should probably have a good reason for reinventing existing wheels. Just don't blame the tools because you didn't do the reading.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fetching files (downloading) from the Internet (extra characters, file handles, file::fetch)
by Anonymous Monk on Nov 25, 2008 at 16:14 UTC | |
by mr_mischief (Monsignor) on Nov 25, 2008 at 16:41 UTC |