Get rid of the
print before you call CGI::scrolling_list() and it'll work. I guess
CGI builds the table first, and then prints it, and the
print call you put in there displays the scrolling list code before it puts it in the table. Same goes for the print before you call img().