in reply to printing last 100 keys from hash

I can see two issues with your example.

1. As DrHyde says the order of a hash is not defined the way one expects. You will have do an explicit sort, depending of the value of your keys, the default sort may suffice or you may have to create an appropriate sort function.

2. Your use of the Range operator is not correct. The right argument must be larger than the left.

This should lead to something along the lines of

for (grep defined($_), (sort keys %db)[-100 .. -1]) {
HTH