Looks 90% like it's Perl. At least these are all valid Perl statements.
Without giving me a look at a larger part of your program I can't find out what's wrong.
For example, you said popup_menu() doesn't work, but you didn't give us at a look of the full implementation of the subroutine, and what you are trying to pass to the subroutine.