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