package Location; use integer; use constant X=>0; use constant Y=>1; sub new{ my($self,$x,$y)=@_; bless[$x,$y],$self; } # this part can be obviously autoloaded sub get_X{ my $self=shift; return $self->[X]; } sub get_Y{ my $self=shift; return $self->[Y]; }