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

后端 未结 5 1165
我在风中等你
我在风中等你 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:25

    I went looking for the same thing and found this lovely little Perl function, explicitly meant to generate results like print_r().

    The author of the script was asking your exact question in a forum here.

    print objectToString($json_data);
    

    Gives this output:

    HASH {
    time                             => 1233173875
    error                            => 0
    node                             => HASH {
        vid                              => 1011
        moderate                         => 0
        field_datestring                 => ARRAY {
            HASH {
                value                            => August 30, 1979
            }
        }
    
        field_tagged_persons             => ARRAY {
            HASH {
                nid                              => undef
            }
        }
    
    ...and so on...
    

提交回复
热议问题