It might be worth pointing out
Array::Unique on CPAN which, if you want an array of unique values, transparently handles it for you.
Granted, you still have to
sort the array but your problem has been reduced to a ten-second job with reusable components, which is
often a good thing.
MB