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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With