7
|
3
|
50
|
|
3
|
0
|
20
|
package OptArgs2::OptArgBase;our$_HAS;sub OptArgs2::OptArgBase_CI::import {shift;$_HAS={@_ > 1 ? @_ : %{$_[0]}};$_HAS=$_HAS->{'has'}if exists$_HAS->{'has'}}sub __RO {my (undef,undef,undef,$sub)=caller(1);Carp::croak("attribute $sub is read-only")}sub __CHECK {if (my@missing=grep {not exists $_[0]->{$_}}'comment','isa','name'){Carp::croak('OptArgs2::OptArgBase attribute(s) required: ' .join(', ',@missing))}no strict 'refs';my$_attrs=*{ref($_[0]).'::_ATTRS'};map {delete$_attrs->{$_}}keys %$_HAS}sub comment {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'comment'}}sub default {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'default'}}sub getopt {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'getopt'}}sub isa {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'isa'}}sub isa_name {if (@_ > 1){$_[0]{'isa_name'}=$_[1];return $_[0]}$_[0]{'isa_name'}}sub name {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'name'}}sub required {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'required'}}sub show_default {$_[0]->__RO($_[1])if @_ > 1;$_[0]{'show_default'}}BEGIN {$INC{'OptArgs2/OptArgBase.pm'}=__FILE__} |