use strict; use warnings; use Test::More tests => 2; use List::MoreUtils 'uniq'; my $v = 'ovedpo15'; my $href = { $v => [5, 3, 2] }; pushsortuniq ($href->{$v}, 3); is_deeply ($href->{$v}, [2, 3, 5], 'Duplicate added, sorted'); pushsortuniq ($href->{$v}, 4); is_deeply ($href->{$v}, [2, 3, 4, 5], 'Non-duplicate added, sorted'); sub pushsortuniq { my ($aref, @topush) = @_; push @$aref, @topush; @$aref = sort (uniq(@$aref)); }