my %rooms = ( townsquare => { name => 'Town Square' east => 'store', }, store => { name => 'Town Store', west => 'townsquare', } ); my %room = (); # create rooms without connections while (my ($id,$roominfo) = each %rooms) { $room{$id} = Room->new($roominfo->{name}); } # since we now already have all room objects, # it's easier to add connections to them while (my ($id, $roominfo) = each %rooms) { for (qw(east west north south)) { $room{$id}->"add$_"($room{$roominfo->{$_}}); } }