my $grey = Color->new( 128 ); my $dark_grey = Color->new( 54 ); my $new_color = $grey + $dark_grey; $new_color += Color->new( 11 ); print $new_color->{color}; { package Color; sub new { my $class = shift; return bless { color=>shift }, $class; } use overload '+' => \&ol, offload => 1; sub ol { my ( $one, $two ) = @_; if ($one->{color} > $two->{color}) { ($one, $two) = ($two, $one); } my $diff = $two->{color} - $one->{color}; return Color->new( $one->{color} + ($diff / 2) ); } }