I have two Perl arrays of equal length, for example-
@year = ('1995', '2003', '1997', '1995', '2012');
@title = ('dog', 'rabbit', 'tiger', 'lion', 'elephant');
I would like to convert them into a hash with years as key and titles as value so I can sort them, manipulate them etc, but converting them into a direct hash will remove the duplicates such as 1995 occurring twice.
What is the best way to convert this data into a hash while preserving duplicate instances of keys?
{ key1 => (val1, val2), key2 => (val1), ... }
. – Kevin Richardson