What is Perl's equivalent to PHP's print_r()?

后端 未结 5 1163
我在风中等你
我在风中等你 2021-02-05 03:59

I find print_r in PHP extremely useful, but wonder if there is anything remotely equivalent in Perl?

5条回答
  •  太阳男子
    2021-02-05 04:17

    As usually with Perl, you might prefer alternative solutions to the venerable Data::Dumper:

    • Data::Dump::Streamer has a terser output than Data::Dumper, and can also serialize some data better than Data::Dumper,
    • YAML (or Yaml::Syck, or an other YAML module) generate the data in YAML, which is quite legible.

    And of course with the debugger, you can display any variable with the 'x' command. I particularly like the form 'x 2 $complex_structure' where 2 (or any number) tells the debugger to display only 2 levels of nested data.

提交回复
热议问题