Consider using a different storage format. I would choose JSON:
|Format||Human readable||Arbitary structures|
(See update below)
|8-bit clean||Version independant||Cross language||May execute code from file||Unexpected network access||Memory usage attack||Comments|
|Perl source code (generated manually or by tools like Data::Dumper)||kind of||yes||yes||mostly||no (only perl can parse Perl)||yes||by executable code||by executable code||yes|
|Storable||no||yes||yes||no (depends on Perl version, limited compatibility with other versions)||no||no||no||no||no|
- \x00 is illegal in XML, workaround like base64 required
- any amount of whitespace is often treated as a single space (CDATA required)
|YAML||yes (but with strange rules)||yes||yes||yes||yes||yes (may be disabled)||by executabe code||by executabe code||yes|
|INI||yes||no, only HoH||no (escaping rules depend on reader and writer)||yes||yes||no||no||no||yes|
|CSV||yes||no, only 2D-Array (AoA)||no (escaping rules depend on reader and writer)||yes||yes||no||no||no||no|
See also Re^4: The safety of string eval and block eval. and Re^2: Storing state of execution
"Arbitary structures" was not meant as arbitary as I wrote, thanks tobyink++. It should read something like "any mix of scalars, arrays, and hashes, without circular references, handles, code references, globs".
"Memory usage attack" means that either the parsed file uses significantly more memory (several orders of magnitute) than the file size, or parsing the file may execute code that allocates much memory.
"Unexpected network access" means either that parsing the file completely and correctly may require reading additional data from the internet, or parsing the file may execute code that accesses the network.
"8 bit clean" means that any binary data may be stored and fetched.
Added comments column
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||