GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Printer::Profile(3) User Contributed Perl Documentation Data::Printer::Profile(3)

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

    package Data::Printer::Profile::MyProfile;

    sub profile {
        return {
            show_tainted => 1,
            show_unicode => 0,
            array_max    => 30,

            # ...and so on...
        }
    }
    1;

Then put in your '.dataprinter' file:

    profile = MyProfile

or load it at compile time:

    use DDP profile => 'MyProfile';

or anytime during execution:

    p $some_data, profile => 'MyProfile';

Usually a ".dataprinter" 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!

Or maybe you just want to be able to upload your settings to CPAN and load them easily anywhere, as shown in the SYNOPSIS.

For all those cases, use a profile class!

Simply create a module named "Data::Printer::Profile::MyProfile" (replacing, of course, "MyProfile" for the name of your profile).

That class doesn't have to inherit from "Data::Printer::Profile", nor add Data::Printer as a dependency. All you have to do is implement a subroutine called "profile()" that returns a hash reference with all the options you want to use.

Profiles are read first and expanded into their options. So if you have a profile called MyProfile with, for example:

    show_tainted = 0
    show_lvalue  = 0

And your ".dataprinter" file contains something like:

    profile     = MyProfile
    show_lvalue = 1

The specific 'show_lvalues = 1' will override the other setting in the profile and the final outcome will be as if your setup said:

    show_tainted = 0
    show_lvalue  = 1

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 "p()" or "np()", then the profile will override any previous settings - though it will still be overriden by other inline arguments.

Data::Printer Data::Printer::Filter
2021-02-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.