.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 3pm" .TH Data::Printer::Profile 3pm 2024-04-27 "perl v5.38.2" "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 CPAN and load them easily anywhere, as shown in the SYNOPSIS. .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, "MyProfile" 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(CWprofile()\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(CWp()\fR or \f(CWnp()\fR, then the profile will override any previous settings \- though it will still be overridden by other inline arguments. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Printer Data::Printer::Filter