laziness, impatience, and hubris | |
PerlMonks |
parsing @ARGV with Getopt::Long multiple timesby bliako (Monsignor) |
on Apr 01, 2020 at 12:11 UTC ( [id://11114902]=perlquestion: print w/replies, xml ) | Need Help?? |
bliako has asked for the wisdom of the Perl Monks concerning the following question: I think I need to call Getopt::Long twice. The first time I take from user the name of the configuration file (say --config abc). Then I read the file, and create a hash of parameters. Then, as a 2nd pass, I need to overwrite any of these parameters in the config with user-specified values from the command line for this particular run. The config hash is too nested, so I just can't pass it to Getopt (like it is mentioned in the doc). And so I resort to this:
Is there a more elegant way? I mean 2 passes, and then the $dummy? Modifying @ARGV between 1st pass and 2nd pass is not acceptable as a new can of worms will be opened (edit: or is it a question of 2 shifts?). bw, bliako
Back to
Seekers of Perl Wisdom
|
|