in reply to How do you run a subroutine from inside HTML code?

Which is the name of the subroutine, the $index?

At first I thought you might be needing someting like HTML::Template or TemplateToolkit - that is, if you wanted to fill a space in the table with the result of the subroutine.

You'd call the subroutine as {$index}(), I think.

On second thought, you may be trying to do some AJAX related stuff. In that case, I suggest you look at CGI::Ajax