in reply to what is keys %$hash_ref [-1]

Did you perhaps mean (...)[-1]?

That's a list slice. The expression in the parens is evaluated in list context. The expression in the square brackets must return a list of indexes. The slice returns the elements of the returned list identified by the indexes. Negative indexes are relative to the end of the list, where -1 is the last element of the list.

( grep { $_ % 4 == 0 } 1..10 ) )[-1] # The last num divisible by 4.