package PointX; use strict; use warnings; use Scalar::Util qw(refaddr); use Carp qw(carp cluck croak confess); our $VERSION = '0.1b'; { my %xcord; my %ycord; sub new { my ($class, $cords) = @_; my $new_object = bless \do{my $anon_scalar;}, $class; $xcord{refaddr $new_object} = $cords->{'x'}; $ycord{refaddr $new_object} = $cords->{'y'}; return $new_object; } sub DESTROY { my ($self) = @_; delete $cord{refaddr $self}; return; } sub set_x { my($self, $xcord) = @_; $xcord{refaddr $self} = $xcord; return ($xcord{refaddr $self}); } sub get_x { my($self) = @_; return ($xcord{refaddr $self}); } sub set_y { my($self, $ycord) = @_; $ycord{refaddr $self} = $ycord; return ($ycord{refaddr $self}); } sub get_y { my($self) = @_; return ($ycord{refaddr $self}); } } # end of internal scoping. 1;