Perl 模块的工作方式类似于 Data::Dumper 但允许数据操作
是否有一个流行的 Perl 模块,其工作方式类似于 Data::Dumper,但允许用户编写钩子来操作复杂结构或对象内的数据。
谷歌中显示了一些模块,例如 Data::Visitor
或 Data::Structure::Util
可以完成这项工作,但我不确定是否可以他们是受欢迎的。
Is there a popular Perl module that works like Data::Dumper
but allows user to write hook to manipulate the data inside complex structure or object.
There are a few modules showing up in google such as Data::Visitor
or Data::Structure::Util
that might do the job, but I'm not sure if they are the popular ones .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经编写了 Data::Dmap 来执行此操作,但正如前面提到的,
Data::Rmap
、Data::Transformer
和Data::Visitor
> 也相关。Data::Dmap
的基本思想是,它允许您转换嵌套数据结构中的任何内容,并且仍然尝试像内置地图函数一样运行。I've written Data::Dmap to do this, but as mentioned,
Data::Rmap
,Data::Transformer
andData::Visitor
are also relevant.The basic idea of
Data::Dmap
is that it allows you to transform anything in a nested data structure and still tries to behave like the built in map function.我不确定这就是你的意思,但是 Data::Dump 支持挂钩过滤转储的数据。 Data::Printer 中也可以使用类似的挂钩。
编辑:如果您需要编辑,我会查看数据:: Rmap 或 Data::Transformer。另外,如果你的结构很简单(比如只有标量、散列和数组),你可以自己进行简单的递归遍历。
I am not sure it is what you mean, but Data::Dump supports hooks to filter dumped data. Similar hooks are also possible in Data::Printer.
Edit: If you need editing, I would look at Data::Rmap or Data::Transformer. Also, if your structure is simple (say only scalars, hashes and arrays), you can make simple recursive traversal yourself.
YAML
是一种很好的序列化格式,易于编辑字符串值等。它可能无法处理所有对象,但值得一试,并且它可以轻松序列化和重新加载事物。YAML
is a nice serialization format, easy to edit string values and such. It might not handle all your objects, but it's worth a try, and it both serializes and reloads things easily.