in reply to Understanding how sort uniq works

ovedpo15:

Perhaps you might try:

my ($k, $g, $a, $v, $f, $c) = split /,/, $line; if (defined $href->{$v}) { $href->{$v} = [ sort uniq @{$href->{$v}} ]; }

I've not tested it, but the intent is to get rid of @temp_array. To do so, I put @{$href->{$v}} after uniq to pass in the contents of the array since I'm guessing that uniq isn't expecting an array reference. I've also wrapped the sort in [ and ] to put the returned array back into $href->{$v} as an array reference.

Update: On re-reading your question, I think I'd try this instead:

my ($k, $g, $a, $v, $f, $c) = split /,/, $line; $href->{$v} = [ sort uniq $a, @{$href->{$v}} ];

Again, it's untested.

...roboticus

When your only tool is a hammer, all problems look like your thumb.