File: try_me.pl

package info (click to toggle)
libdata-printer-perl 1.000001-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 692 kB
  • sloc: perl: 4,208; makefile: 7
file content (55 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env perl
use strict;
use warnings;
use Scalar::Util qw(weaken);

# This sample code is available to you so you
# can see Data::Printer working out of the box.
# It can be used as a quick way to test your
# color palette scheme!
package My::BaseClass;
sub whatever {}

package My::SampleClass;
use base 'My::BaseClass';
sub new { bless {}, shift }
sub public_method { 42 }
sub _private_method { 'sample' }


package main;

my $obj = My::SampleClass->new;

my $sample = {
  number => 123.456,
  string => 'a string',
  array  => [ "foo\0has\tescapes", 6, undef ],
  hash   => {
    foo => 'bar',
    baz => 789,
  },
  readonly => \2,
  regexp => qr/foo.*bar/i,
  glob   => \*STDOUT,
  code   => sub { return 42 },
  class  => $obj,
};

$sample->{weakref} = $sample;
weaken $sample->{weakref};

BEGIN { $ENV{DATAPRINTERRC} = '' };  # <-- skip user's .dataprinter

use DDP show_memsize  => 1,
        show_refcount => 1,
        class => {
            format_inheritance => 'lines',
            inherited  => 'public',
            linear_isa => 1
        };

p $sample, theme => 'Material' , as => 'Material theme:';
p $sample, theme => 'Solarized', as => 'Solarized theme:';
p $sample, theme => 'Monokai', as => 'Monokai theme:';
p $sample, theme => 'Classic', as => 'Classic pre-1.0 theme:';