in reply to
Re^2: Can @ARGV work within Perl functions or is it just for script input?
in thread Can @ARGV work within Perl functions or is it just for script input?
Even in those cases, there are usually clearer solutions...
use Getopt::Long qw( GetOptionsFromArray );
sub do_awesome_things {
GetOptionsFromArray( \@_,
'files=s' => \my @files,
'verbose!' => \my $verbose,
);
warn "Going to process files @files. "
. "Verbose is ".( $verbose ? 'ON' : 'OFF' ).".\n";
}
do_awesome_things -v => -file => 'foo.txt', -file => 'bar.txt';