in reply to Print the key of the first hash table in hash of hashes

$samplehash{$key} is a hashref. You're accessing its keys with $samplehash{$key}{$subkey}.

I'd recommend using Data::Dumper to see the entire contents and structure of %samplehash. I suspect that when you visualise the whole data structure, the reasons for your output will become apparent.

-- Ken