in reply to Getopt::Long on Variable?
Add the data to @ARGV.
#!/usr/bin/perl -w use strict; use Getopt::Long; my $size = 1; { local @ARGV = qw/ --size 20 /; GetOptions( 'size=s' => \$size ); } print 'x' x $size;
That being said, exactly what are you trying to accomplish? Getopt::Long is designed to allow the person using the program to modify the program's behavior. If you wish to control the behavior from within the program, why don't you just assign to the variables directly? You could also use config files for different environments, if that is what you are looking for.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|