1Data::Printer::Profile(U3s)er Contributed Perl DocumentatDiaotna::Printer::Profile(3)
2
3
4

NAME

6       Data::Printer::Profile - customize your Data::Printer with code
7

SYNOPSIS

9           package Data::Printer::Profile::MyProfile;
10
11           sub profile {
12               return {
13                   show_tainted => 1,
14                   show_unicode => 0,
15                   array_max    => 30,
16
17                   # ...and so on...
18               }
19           }
20           1;
21
22       Then put in your '.dataprinter' file:
23
24           profile = MyProfile
25
26       or load it at compile time:
27
28           use DDP profile => 'MyProfile';
29
30       or anytime during execution:
31
32           p $some_data, profile => 'MyProfile';
33

DESCRIPTION

35       Usually a ".dataprinter" file is enough to customize Data::Printer. But
36       sometimes you want to use actual code to create special filters and
37       rules, like a dynamic color scheme depending on terminal background or
38       even the hour of the day, or a custom message that includes the
39       hostname. Who knows!
40
41       Or maybe you just want to be able to upload your settings to CPAN and
42       load them easily anywhere, as shown in the SYNOPSIS.
43
44       For all those cases, use a profile class!
45
46   Creating a profile class
47       Simply create a module named "Data::Printer::Profile::MyProfile"
48       (replacing, of course, "MyProfile" for the name of your profile).
49
50       That class doesn't have to inherit from "Data::Printer::Profile", nor
51       add Data::Printer as a dependency. All you have to do is implement a
52       subroutine called "profile()" that returns a hash reference with all
53       the options you want to use.
54
55   Load order
56       Profiles are read first and expanded into their options. So if you have
57       a profile called MyProfile with, for example:
58
59           show_tainted = 0
60           show_lvalue  = 0
61
62       And your ".dataprinter" file contains something like:
63
64           profile     = MyProfile
65           show_lvalue = 1
66
67       The specific 'show_lvalues = 1' will override the other setting in the
68       profile and the final outcome will be as if your setup said:
69
70           show_tainted = 0
71           show_lvalue  = 1
72
73       However, that is of course only true when the profile is loaded
74       together with the other settings. If you set a profile later, for
75       instance as an argument to "p()" or "np()", then the profile will
76       override any previous settings - though it will still be overriden by
77       other inline arguments.
78

SEE ALSO

80       Data::Printer Data::Printer::Filter
81
82
83
84perl v5.34.0                      2022-01-21         Data::Printer::Profile(3)
Impressum