Actually i have to correct the code I posted before. while ( my ($k,$val) = each %{ +GROUPS } ) { So my actual question is, how I can use $k in each(), so that it represents A and B. while ( my ($name,$value) = each ( what I have use here?)) { print $name{value} ; } }