开发者

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! ;-)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜