package XX::Maximum;
sub new { my ( $class, $value ) = @_; bless \$value, $class }
sub set { ${$_[0]} = $_[1] }
sub get { ${$_[0]} }
sub insert {
return ${$_[0]} unless defined $_[1];
return ${$_[0]} = ( !defined(${$_[0]} ) ? $_[1] : ( ${$_[0]} > $_[1]
+ ? ${$_[0]} : $_[1] ));
}
package main;
my $t = XX::Maximum->new;
$t->insert(1);
$t->insert(0);
$t->insert(undef);
print $$t, "\n";
$t->insert(-10);
print $$t, "\n";
$t->insert(10);
print $$t, "\n";
print $t->get, "\n";
$t->set(undef);
|