in reply to Checking if an item exists in an array before adding a record to it.

If you find that your choice of data-structure is getting in the way of writing clean logic, then change structure!

Use a hash from the outset, rather than gin up some convoluted check-for-existence routine that converts from arrays to hashes and back and forth. Once you have your data in a hash, you can print it easily enough in what ever order is most appropriate. (I am very fond of the sort(keys(%my_hash)) .... idiom in a foreach loop.)

(Written in the hour BC -- Before Coffee, please excuse the typoes).

----
I Go Back to Sleep, Now.

OGB