![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Re: How can I seralize a file for use with XML?by repellent (Priest) |
on Feb 01, 2012 at 06:18 UTC ( #951125=note: print w/replies, xml ) | Need Help?? |
The prevalent XML 1.0 spec forbids the use of most "control" characters (in the range #x00 - #x19), and that makes it a terrible format for shipping binary data. Even if your API requirement starts off as being printable text-only, you'd soon slam hard into this limitation once you demand more out of your XML use. The workaround is to encode your binary data (e.g. Base64) into an XML-compatible string that you can embed in the XML. This introduces an extra decoding step when you want to get back at your binary data.
Consider that what you want is to get that Perl hash safely across. Why not just ship binary data across using Storable?
Or use a format like JSON? See JSON::XS. If all you care about is to ship the files across, then consider using Archive::Tar with compression as a way of packaging the files. The tar object can read/write from filehandles and would work with sockets.
In Section
Seekers of Perl Wisdom
|
|