Perl hash Data::Dumper

北慕城南 提交于 2019-12-05 01:56:14

I almost always set

$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;

with Data::Dumper. The first statement makes the output more compact and much more readable when your data structure is several levels deep. The second statement makes it easier to scan the output and quickly find the keys you are most interested in.

If the data structure contains binary data or embedded tabs/newlines, also consider

$Data::Dumper::Useqq = 1;

which will output a suitable readable representation for that data.

Much more in the perldoc.

One possible solution is to use Data::Dumper::Perltidy which runs the output of Data::Dump through Perltidy.

#!/usr/bin/perl -w

use strict;
use Data::Dumper::Perltidy;

my $data = [{ title => 'This is a test header' },{ data_range =>
           [ 0, 0, 3, 9] },{ format     => 'bold' }];

print Dumper $data;

__END__

Prints:

$VAR1 = [
    { 'title'      => 'This is a test header' },
    { 'data_range' => [ 0, 0, 3, 9 ] },
    { 'format'     => 'bold' }
];

Another way is to use Data::Dump.

user2524042
$Data::Dumper::Sortkeys = 1;

If you want to get a more reliable result then you have to follow the dumper next. Put in the suitable word to operate that function.

This answers the question.

my $WWW_Scripter_Plugin_JavaScript_JE = ${ $VAR1->[1]{156192192} };
my $JE_Object_String = ${ $WWW_Scripter_Plugin_JavaScript_JE->{pf}{String} };
my $JE_Object_Function = ${ $JE_Object_String->{props}{search} };
my $REF = ${ $JE_Object_Function->{global} };
my $HTML_DOM_Element_Img = $REF->{classes}{'HTML::DOM::Element::Img'};

It also violates encapsulation. Perl lets you do it, but you should rather ask how to get at the data with the published WWW::Scripter API.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!