« ColorTheme/Data/Dump/Color/Default16.pm
↑ Summary
auto/share/dist/Data-Dump-Color/examples/example2.pl »
| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use Data::Dump::Color; | ||
| 4 | |||
| 5 | dd({ | ||
| 6 | undef => undef, | ||
| 7 | |||
| 8 | # strings | ||
| 9 | str => 'Jason', | ||
| 10 | str_empty => '', | ||
| 11 | str_with_newlines => "Mark\nJason\nDominus", | ||
| 12 | |||
| 13 | # numbers | ||
| 14 | num_int => 45, | ||
| 15 | num_neg_int => -45, | ||
| 16 | num_float => 0.23, | ||
| 17 | num_neg_float => -0.23, | ||
| 18 | num_str_int => "45", | ||
| 19 | num_neg_str_int => "-45", | ||
| 20 | num_str_float => "0.23", | ||
| 21 | num_neg_str_float => "-0.23", | ||
| 22 | num_nan => nan, | ||
| 23 | num_inf => inf, | ||
| 24 | num_neg_nan => -nan, | ||
| 25 | num_neg_inf => -inf, | ||
| 26 | num_exp => 1.2e+100, | ||
| 27 | num_neg_exp => -1.2e-101, | ||
| 28 | |||
| 29 | # arrays | ||
| 30 | array => [1, 2.2, "3", "a", "b", undef, []], | ||
| 31 | array_empty => [], | ||
| 32 | array_long => [qw/For backward compatibility with older implementations that | ||
| 33 | didn't support anonymous globs/], | ||
| 34 | array_aoh_mostly => [ | ||
| 35 | { name => 'Andi', dob => '1988-10-10', employee_id=>1, some_other_attribute => 'some value', }, | ||
| 36 | { name => 'Budi', dob => '1983-01-22', employee_id=>2, some_other_attribute => 'some value', }, | ||
| 37 | { name => 'Cika', dob => '1986-07-03', employee_id=>3, some_other_attribute => 'some value', }, | ||
| 38 | "this one is not a hash", | ||
| 39 | ], | ||
| 40 | |||
| 41 | # hashes | ||
| 42 | hash => {a=>1, b=>2, c=>[], d=>{}, e=>undef}, | ||
| 43 | hash_empty => {}, | ||
| 44 | hash_long => {qw/For backward compatibility with older implementations that | ||
| 45 | didn't support anonymous globs/}, | ||
| 46 | hash_hoh_mostly => { | ||
| 47 | EMP001 => { name => 'Andi', dob => '1988-10-10', employee_id=>'EMP001', some_other_attribute => 'some value', }, | ||
| 48 | EMP002 => { name => 'Budi', dob => '1983-01-22', employee_id=>'EMP003', some_other_attribute => 'some value', }, | ||
| 49 | EMP3 => { name => 'Cika', dob => '1986-07-03', employee_id=>'EMP3' , some_other_attribute => 'some value', }, | ||
| 50 | key4 => "this one is not a hash", | ||
| 51 | }, | ||
| 52 | |||
| 53 | # objects | ||
| 54 | obj => bless({a=>1, b=>2}, "Foo"), | ||
| 55 | |||
| 56 | # others | ||
| 57 | regexp => qr/^ab(?:cd)$/i, | ||
| 58 | glob => \*FOO, | ||
| 59 | circular => do { my $a = [1]; push @$a, $a; $a }, | ||
| 60 | }); |