这是一种什么样的数据格式?
我有一堆以下形式的数据文件:
("String"
:tag1 (value)
:tag2 (value2)
:tag3 (
:nested_tag1 (foo)
:nested_tag2 (
:nested2_tag1 (
: ( nested3_tag1
:baz (true)
:qux ("a really long block of text")
)
)
)
)
)
这只是一个小例子。真实的文件有数千行。
原谅我的无知,但我不认识这种格式。这是常见或已知的格式吗?它有名字吗?
我想用 Perl 处理它,想知道是否有任何外部模块可以让我轻松地将其转换为 Perl 数据结构 - 而无需我自己编写解析器。毕竟,为什么要重新发明轮子呢! ;-)
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! ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这看起来像 Lisp 风格的 S-Expression。例如,Emacs 在将示例引用为列表后会很好地理解您的示例。
S 表达式通常非常容易解析,而且 CPAN 搜索 S 表达式应该足以让您不必自己编写解析器。
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.