.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Data::Printer::Profile 3"
.TH Data::Printer::Profile 3 "2021-02-24" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Data::Printer::Profile \- customize your Data::Printer with code
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& package Data::Printer::Profile::MyProfile;
\&
\& sub profile {
\& return {
\& show_tainted => 1,
\& show_unicode => 0,
\& array_max => 30,
\&
\& # ...and so on...
\& }
\& }
\& 1;
.Ve
.PP
Then put in your '.dataprinter' file:
.PP
.Vb 1
\& profile = MyProfile
.Ve
.PP
or load it at compile time:
.PP
.Vb 1
\& use DDP profile => \*(AqMyProfile\*(Aq;
.Ve
.PP
or anytime during execution:
.PP
.Vb 1
\& p $some_data, profile => \*(AqMyProfile\*(Aq;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Usually a \f(CW\*(C`.dataprinter\*(C'\fR file is enough to customize Data::Printer. But
sometimes you want to use actual code to create special filters and rules,
like a dynamic color scheme depending on terminal background or even the
hour of the day, or a custom message that includes the hostname. Who knows!
.PP
Or maybe you just want to be able to upload your settings to \s-1CPAN\s0 and load
them easily anywhere, as shown in the \s-1SYNOPSIS.\s0
.PP
For all those cases, use a profile class!
.SS "Creating a profile class"
.IX Subsection "Creating a profile class"
Simply create a module named \f(CW\*(C`Data::Printer::Profile::MyProfile\*(C'\fR
(replacing, of course, \*(L"MyProfile\*(R" for the name of your profile).
.PP
That class doesn't have to inherit from \f(CW\*(C`Data::Printer::Profile\*(C'\fR, nor
add Data::Printer as a dependency. All you have to do is implement a
subroutine called \f(CW\*(C`profile()\*(C'\fR that returns a hash reference with
all the options you want to use.
.SS "Load order"
.IX Subsection "Load order"
Profiles are read first and expanded into their options. So if you have a
profile called MyProfile with, for example:
.PP
.Vb 2
\& show_tainted = 0
\& show_lvalue = 0
.Ve
.PP
And your \f(CW\*(C`.dataprinter\*(C'\fR file contains something like:
.PP
.Vb 2
\& profile = MyProfile
\& show_lvalue = 1
.Ve
.PP
The specific 'show_lvalues = 1' will override the other setting in the profile
and the final outcome will be as if your setup said:
.PP
.Vb 2
\& show_tainted = 0
\& show_lvalue = 1
.Ve
.PP
However, that is of course only true when the profile is loaded together with
the other settings. If you set a profile later, for instance as an argument to
\&\f(CW\*(C`p()\*(C'\fR or \f(CW\*(C`np()\*(C'\fR, then the profile will override any previous settings \-
though it will still be overriden by other inline arguments.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Data::Printer
Data::Printer::Filter