use strict; my %hashes = ( other0 => { 'cat0'=>'3', 'cat1'=>'3' }, other1 => {} ); my @catnames = ('other0','other1'); print $hashes{$catnames[0]}->{cat0},"\n";