rewrite get-obj-values script in Perl (fixed a sorting bug as well)