sub my_uniq { my $self = shift; my @result = uniq @{ $self->list }; wantarray ? @result : scalar @result; } #### sub my_uniq { my $self = shift; return uniq @{ $self->list }; } #### # class method sub get_list { my $self = shift; return @{ $self->list() }; } #### # client code - variant a # (client wants values and count) my @uniq_list = uniq $obj->get_list(); my $uniq_count = scalar @uniq_list; # client code - variant b # (client just wants the count) my $uniq_count = scalar uniq $obj->get_list();