in reply to LoH Incrementing Autovivification

Why are you calling keys in a scalar context?

If you expect only a single key, use:

my ($key) = keys %$_;
If you want to iterate, add an inner loop:
for my $key (keys %$_) { .... }

-- Randal L. Schwartz, Perl hacker