sub make_accessor { my ($index) = $_[2]; no strict 'refs'; *{ref($_[0]) . "::$_[1]"} = sub { return $_[0]->[$index] unless @_ > 1; $_[0]->[$index] = $_[1]; $_[0]; }; 1; }