package SetObject; use overload 'eq' => \&str_compare, '==' => \&num_compare, fallback => 1; use base 'Exporter'; @EXPORT = 'Set'; sub Set { return bless [ @_ ], __PACKAGE__; } sub str_compare { my ($self, $other, $swap) = @_; for my $val (@$self) { return 1 if $val eq $other; } return 0; } sub num_compare { my ($self, $other, $swap) = @_; for my $val (@$self) { return 1 if $val == $other; } return 0; } 1;