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

It is syntax error