Looking at the documentation of Data::Dumper, I think you'd be best off by writing appropriate Freezer and Toaster subroutines, but there is $Data::Dumper::Bless which you can set to a subroutine name of your own choosing instead to load the target module:
#!perl use 5.020; use Data::Dumper; $Data::Dumper::Deparse=1; $Data::Dumper::Bless="my_bless"; package Foo {}; say Dumper bless { name => "foo" } => "Foo"; __END__ $VAR1 = my_bless( { 'name' => 'foo' }, 'Foo' );
On the receiving side, you can then implement my_bless as:
sub my_bless( $ref, $class ) { require $class; bless $ref => $class; }
But again, implementing the appropriate Freezer and Toaster is much saner than using Data::Dumper and eval.
In reply to Re: Class / package weak association
by Corion
in thread Class / package weak association
by dd-b
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |