
davorg
Thaumaturge
/ Moderator
Mar 5, 2003, 1:50 AM
Post #2 of 3
(312 views)
|
|
Re: [bkreitman] Using GetOpts on something other than @ARGV
[In reply to]
|
Can't Post
|
|
The Getopts functions only work on @ARGV because that's where the command line options are held. I haven't tried it, but it should be possible to set @ARGV to some other value and then use the functions. You can use "local" and a naked block to prevent @ARGV becoming corrupted.
{ local @ARGV; @ARGV = @some_other_data; getopts("..."); } # @ARGV now has its original value. -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|