http://www.perlmonks.org?node_id=566873


in reply to Overriding arguments in Class::Std superclass constructors

Try using Object::InsideOut. It will do just what you want:
#!/usr/bin/perl use strict; use warnings; package My::Class; { use Object::InsideOut; my @value :Field('Accessor' => 'value'); my %init_args :InitArgs = ( 'value' => { 'Field' => \@value, 'Mandatory' => 1, }, ); } package My::Class::Sub; { use Object::InsideOut qw(My::Class); sub _preinit :PreInit { my ($self, $args) = @_; $args->{'value'} = 23; } } package main; my $obj = My::Class::Sub->new(); print($obj->value(), "\n");

Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^2: Overriding arguments in Class::Std superclass constructors
by fce2 (Sexton) on Aug 13, 2006 at 03:46 UTC
    Unfortunately I didn't learn about Object::InsideOut until a few weeks into this project, so its too late to switch. Possibly for the next version, we'll see. Thanks for the example though, its good to know the possibility exists.