use warnings; use strict; my %hash; $hash{three}{levels}{deep} = 7500; $hash{process}{three}{levels}{deep} = 9000; for my $process(qw/ process no_process /){ my $hashbase; if (exists $hash{$process}){ $hashbase = $hash{$process}; } else { $hashbase = \%hash; } print "$process - ",$hashbase->{three}{levels}{deep},"\n"; }