Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Data-Printer CPAN distribution.

Report information
The Basics
Id: 82147
Status: resolved
Priority: 0/
Queue: Data-Printer

People
Owner: Nobody in particular
Requestors: xenoterracide [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: support for most dumper import api
Date: Thu, 20 Dec 2012 18:29:49 -0600
To: bugs-data-printer [...] rt.cpan.org
From: Caleb Cushing <xenoterracide [...] gmail.com>
I have the following code for debugging. It allows people to inject whatever dumper they want. https://metacpan.org/source/HGDEV/Business-CyberSource-0.007010/lib/Business/CyberSource/Client.pm#L74 I get that `p()` is more humanly friendly, but it'd be nice if you could support importing like use Module::Load; load 'Data::Printer', 'Dumper'; this would allow people to set Data::Printer for my module. (a side note, I notice the way I call my code with print that it removes color formatting, is it possible to prevent this?) -- Caleb Cushing http://xenoterracide.com
On Thu Dec 20 19:30:03 2012, XENO wrote: Hi Caleb! Sorry for not replying earlier, I was on vacation :) Show quoted text
> I have the following code for debugging. It allows people to inject > whatever dumper they want. > > https://metacpan.org/source/HGDEV/Business-CyberSource- > 0.007010/lib/Business/CyberSource/Client.pm#L74 > > I get that `p()` is more humanly friendly, but it'd be nice if you > could support importing like > > use Module::Load; > load 'Data::Printer', 'Dumper'; > > this would allow people to set Data::Printer for my module.
You can already do this: --------8<-------- use Module::Load; load 'Data::Printer', alias => 'Dumper'; my $x = [1, 42, 99]; Dumper( $x ); # works just like p()! -------->8-------- Is that what you meant? Show quoted text
> > (a side note, I notice the way I call my code with print that it > removes color formatting, is it possible to prevent this?)
Sure! just pass: color => 'always' as a parameter, just like I did to 'alias' up there. Cheers! garu
Subject: Re: [rt.cpan.org #82147] support for most dumper import api
Date: Sun, 13 Jan 2013 22:21:46 -0600
To: bug-Data-Printer [...] rt.cpan.org
From: Caleb Cushing <xenoterracide [...] gmail.com>
On Sun, Jan 13, 2013 at 12:39 AM, Breno G. de Oliveira via RT <bug-Data-Printer@rt.cpan.org> wrote: Show quoted text
> --------8<-------- > use Module::Load; > load 'Data::Printer', alias => 'Dumper'; > > my $x = [1, 42, 99]; > Dumper( $x ); # works just like p()! > -------->8-------- > > > Is that what you meant?
no not exactly, because that won't work in /this/ code that I linked load $self->_dumper_package, 'Dumper'; you could argue that the problem is that I don't support passing additional parameters, but I was trying to constrain it to the specifics. _dumper_package attribute is constrained to /must be a valid package name/. You can then change the Dumper package name without modifying my source by passing it to the constructor (I thought I was allowing via env variable but I guess not, maybe I should change that). Because most of the Dumper modules support use Module, Dumper; (or should imo). I couldn't generically write load Module, alias => Dumper and expect it to work on Data::Dumper. note: I'm seriously considering writing Dumper::Any due to API inconsistency issues between Dumper modules. Show quoted text
>> >> (a side note, I notice the way I call my code with print that it >> removes color formatting, is it possible to prevent this?)
> > Sure! just pass: > > color => 'always' > > as a parameter, just like I did to 'alias' up there.
yeah I missed that in the docs when I first wrote this, I'm kind of liking how DBIx::QueryLog can set color via an environment variable (again so I can put this outside of the source as this setting is more for human users). -- Caleb Cushing http://xenoterracide.com