in reply to Hash error

Use Tie::IxHash
use strict; use warnings; use Tie::IxHash; tie my %where, 'Tie::IxHash'; %where = ( Gary => "Dallas", Lucy => "Exeter", Ian => "Reading", Samantha => "Oregon" ); for ( keys %where ) { print "$_ lives in $where{$_}\n"; }

This is a FAQ:

perldoc -q hash

How can I make my hash remember the order I put elements into it?

To neaten up your code, see perltidy