in reply to updating code with getopt::long

Getopt::Long is used to parse the command-line. It is not used for passing arguments to a sub.

You could pass another argument to your sub, such as a reference to a hash of options.