Use a locally scoped variable to iterate through the execution of hooks

Previously $_ was used to iterate through the list of hook coderefs to
execute, however the aliasing involved allowed the hooks code to be
replaced if $_ was assigned within the hook code.

Resolves #540.