fce2 has asked for the wisdom of the Perl Monks concerning the following question:

I'm porting a small Java application to Perl, using Class::Std. Now I have a class with a constructor that calls the superclass constructor with certain required fields filled in. An example in Perl might be:
package myclass; use Carp qw(croak); sub new { my ($class, $value) = @_; croak "required value missing" if @_ == 1 or !$value; return bless \$value, $class; } package mysubclass; use base qw(myclass); sub new { my ($class) = @_; return bless $class->SUPER::new(23), $class; }
Now in Class::Std, superclass "constructors" (ie BUILD and START) are called automatically. However, there doesn't seem to be a way to set or override the arguments for a superclass in a subclass. I'd like to do something like this:
package myclass; use Class::Std; my %value :ATTR( :init_arg<value> ); package mysubclass; use base qw(myclass); sub BUILD { my ($self, $ident, $args) = @_; $args->{value} = 23; }
This doesn't work. Even though Class::Std calls BUILD(), then initialises the object from the constructor arguments, and then calls START(), the third argument passed to each BUILD/START method is specific to that method - its discarded afterwards. There doesn't seem to be any way to influence the arguments in this way. Doing this:
Missing initializer label for myclass: 'value'. Fatal error in constructor call
Anyone got any ideas before I open a ticket in RT?