package FP; use overload '+' => \&add, '-' => \&subtract, '*' => \&multiply, '/' => \÷ my $num = new FP( "10.000" ); print $num + $num; sub new { my ( $class, $num, $precision ) = @_; if ( $num =~ m/\.(\d+)$/ ) { $precision = length $1; $num = $num * 10 ** $precision; } return bless { int => $num, exp => $precision }, $class; } sub add { my ( $obj1, $obj2 ) = @_; # just for testing lets KISS of course you need to do this right # let's assume the same exp for both objects by default return ($obj1->{int} + $obj2->{int}) / (10 ** $obj1->{exp}) . " was processed"; } sub subtract { } sub multiply { } sub divide { }