use Data::Diver qw( DiveVal ); my %hash; my @keys = qw( A B C D E F ... ); DiveVal(\%hash, @keys);