Closed hakonhagland closed 8 years ago
Added a pull request trying to fix the problem.
Wow, I was just coming here to report the same issue with using ToolSet with Data::Printer except that I usually use the hashref form:
use Data::Printer {
caller_info => 1,
caller_message => q{Printing line __LINE__ of __FILENAME__:}
};
The forcing of qw()
on the export argument hash values seems to make it impossible either way.
With Data::Printer, a workaround is using an rc_file
:
ToolSet->export(
'DDP' => [ rc_file => "/path/to/my/.dataprinter" ],
);
I'm concerned with the hashref approach of #3 because I think it could get fragile. It also leads me to wonder what to do about import() subs that expect hash references or hash references as the value from some key:
use Foo -someopt => { foo => 1, bar => 2 };
I wonder if giving a way of passing a literal string to the eval would be the most flexible -- then people can put in whatever they need. Eg. having a reference to a string mean that the string should be passed through verbatim:
ToolSet->export( Foo => \"-someopt => { foo => 1, bar => 2 }" );
In the Data::Printer case, it could look like this:
$DP_args = <<'HERE';
caller_info => 1,
caller_message => q{Printing line __LINE__ of __FILENAME__:},
HERE
ToolSet->export( 'Data::Printer' => \$DP_args );
What do you think? I have a branch that has this working, but would like feedback before I ship it.
Good idea! I did not realize that you could use package $caller
inside an eval
like that. Nice. It also seems to work well for my test cases.
Great! I've shipped it to CPAN.
I am not able to export module arguments containing white spaces. For example, with the
Data::Printer
module, I can useIf I try to transfer this to my
ToolSet
package:the argument
q{Printing line __LINE__ of __FILENAME__:}
is split into serveral at white space..How to achieve this?