in reply to CGI: Passing variables to a subroutine
Use the site search functionality to look for "dispatch table" (and seconding on the recommendation to just pass your $query instance).