use Contextual::Return; # Name method offers unconstrained access... sub name : lvalue { my ($self) = @_; $name_of{ident $self}; } # Rank method constrains access: can assign only valid ranks # (value being assigned is passed as $_ to LVALUE block)... sub rank : lvalue { my ($self) = @_; LVALUE { croak "Invalid rank ($_) assigned" if !$is_valid_rank{$_}; $rank_of{ident $self} = $_; } RVALUE { $rank_of{ident $self}; } } # Serial method offers read-only access... sub serial { my ($self) = @_; return $snum_of{ident $self}; }