for my $s2_key (keys %{$rehash{"1"}}) { if ( exists( $rehash{"1"}{$s2_key} )) { print SOMETHING; }