in reply to hash ordered by an array

use Tie::IxHash; tie %order, 'Tie::IxHash', map { $_ => $my_hash{$_}; } @array;