in reply to updating code with getopt::long
You could pass another argument to your sub, such as a reference to a hash of options.