gpt4 book ai didi

perl - 如何控制 Data::Dumper 输出的格式?

转载 作者:行者123 更新时间:2023-12-04 13:00:47 27 4
gpt4 key购买 nike

我正在使用 Data::Dumper::Dumper()方法。输出很好,但可以做得更紧凑,更美观。

我怎么能控制它?什么是更好的选择?

最佳答案

看看Data::Dump对于类似于 Data::Dumper 的东西,但可以说在 pretty-print 方面更好。
编辑 (20120304) :我完全忘记了这个问题,但今天它被点赞了,这让我想起了。如果今天(3 年后)我必须推荐任何用 Perl 进行 pretty-print 的东西,我肯定会选择 Data::Printer .来自 Data::Printer 自己的理由:

Data::Dumper is a fantastic tool, meant to stringify data structures in a way they are suitable for being eval'ed back in.

The thing is, a lot of people keep using it (and similar ones, like Data::Dump) to print data structures and objects on screen for inspection and debugging, and while you can use those modules for that, it doesn't mean mean you should.

This is where Data::Printer comes in. It is meant to do one thing and one thing only:display Perl variables and objects on screen, properly formatted (to be inspected by a human)

关于perl - 如何控制 Data::Dumper 输出的格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1595557/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com