in reply to strange looking code

I assume the line that's confusing you is the following:
@A{keys %r} = keys %r;
Essentially, it's doing the same thing as the following code, which should be a lot easier to understand:
foreach $key (keys %r) { $A{ $key } = $key; }