in reply to Re: Using a 'getopt' in module code
in thread Using a 'getopt' in module code

Getopt works on @ARGV, so you can't use it to process function arguments. Well, not without doing @ARGV = @_ which might well break other stuff.

You can try something like this:

#!/usr/bin/perl use strict; use warnings; use Getopt::Std; use Data::Dumper; sub getopt_fun { my %args; { local @ARGV = @_; getopt 't', \%args; } print Dumper \%args; } getopt_fun (-t => 'foo');

Edit: narrowed the scope of the local.