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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Consider using a different storage format. I would choose JSON:

FormatHuman readableArbitary structures
(See update below)
8-bit cleanVersion independantCross languageMay execute code from fileUnexpected network accessMemory usage attackComments
Perl source code (generated manually or by tools like Data::Dumper)kind ofyesyesmostlyno (only perl can parse Perl)yesby executable codeby executable codeyes
Storablenoyesyesno (depends on Perl version, limited compatibility with other versions)nonononono
XMLyesyesno
  • \x00 is illegal in XML, workaround like base64 required
  • any amount of whitespace is often treated as a single space (CDATA required)
yesyesnoyesyesyes
YAMLyes (but with strange rules)yesyesyesyesyes (may be disabled)by executabe codeby executabe codeyes
JSONyesyesyesyesyesnononono (but some parsers allow Javascript or shell comments)
INIyesno, only HoHno (escaping rules depend on reader and writer)yesyesnononoyes
CSVyesno, only 2D-Array (AoA)no (escaping rules depend on reader and writer)yesyesnononono

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". ;-)

In reply to Re: Accessing variables in an external hash without eval by afoken
in thread Accessing variables in an external hash without eval by victorz22

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found