package Result; use overload 'bool' => \&as_bool, '""' => \&stringify; sub new { if ($_[0] eq __PACKAGE__) { shift; } my $self = { as_bool => $_[0], string => $_[1], }; bless $self, __PACKAGE__; $self; } sub as_bool { my $self = shift; $self->{as_bool}; } sub stringify { my $self = shift; $self->{string}; } 1;