Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of data format is this?

I have a bunch of data files of the following form:

("String"
    :tag1 (value)
    :tag2 (value2)
    :tag3 (
        :nested_tag1 (foo)
        :nested_tag2 (
            :nested2_tag1 (
                 : ( nested3_tag1
                          :baz (true)
                          :qux ("a really long block of text")

                 )
            )
        )
    )
)

This is just a small example. The real files have many thousands of lines.

Forgive my ignorance, but I don't recognise the format. Is this a common or known format? Does it have a name?

I want to process it with Perl and wondered if there were any external modules that would allow me to easily turn it into a Perl data structure - without me having to write a Parser myself. After all, why re-invent the wheel! ;-)

like image 616
wawawawa Avatar asked Apr 14 '11 14:04

wawawawa


1 Answers

To me this looks like a Lisp-ish S-Expression. Emacs, for example, will understand your example just fine after quoting it as a list.

S-Expressions are generally very easy to parse, but also a CPAN search for S-Expressions should give you enough to not have to write a parser yourself.

like image 183
rafl Avatar answered Sep 22 '22 13:09

rafl