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 |
XML | yes | yes | no- \x00 is illegal in XML, workaround like base64 required
- any amount of whitespace is often treated as a single space (CDATA required)
| yes | yes | no | yes | yes | yes |
YAML | yes (but with strange rules) | yes | yes | yes | yes | yes (may be disabled) | by executabe code | by executabe code | yes |
JSON | yes | yes | yes | yes | yes | no | no | no | no (but some parsers allow Javascript or shell comments) |
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
Updates:
"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
Added Data::Dumper
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|