talexb has asked for the wisdom of the Perl Monks concerning the following question:
Has anyone used Getopt::Auto? I'm keen to get it going but haven't been able to get my test code (taken from the man page) to run the way I think it should.
From the man page:
"Getopt::Auto" is happy for you to use "long" ("--gnu-style"), "short" ("-oldstyle") or even "bare" command names, ("myprogram edit foo.txt", CVS-style) on the condition that you are consistent. Additionally, if you use bare or long style commands, then any short options passed before a command name will be sent into %main::options. For instance, given use Getopt::Auto ( "edit" => "open a file for editing", "export" => "write out the data as an ASCII file" ); "yourprog -vt edit -x foo.txt" will perform the following: $main::options{v} = 1 $main::options{t} = 1 edit("-x", "foo.txt");
My code:
#!/usr/bin/perl use strict; use warnings; # Test bed for Getopt::Auto use Getopt::Auto ( [ "edit" => "open a file for editing", "export" => "write out the data as an ASCII file" ] ); our %options; { print "Dump arguments!!\n"; foreach ( keys %main::options ) { print "$_ : $main::options{$_}\n"; } }
The result:
--t. alex[alex@foo dev]$ perl -w go.pl -vt edit -x foo.txt Dump arguments!! Use of uninitialized value in subroutine entry at /usr/lib/perl5/site_ +perl/5.8.0/Getopt/Auto.pm line 140. Can't use string ("") as a subroutine ref while "strict refs" in use a +t /usr/lib/perl5/site_perl/5.8.0/Getopt/Auto.pm line 140. END failed--call queue aborted.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Auto question
by jasonk (Parson) on Feb 20, 2003 at 23:21 UTC | |
by talexb (Chancellor) on Feb 21, 2003 at 03:39 UTC | |
by Hofmator (Curate) on Feb 21, 2003 at 08:50 UTC | |
by talexb (Chancellor) on Feb 21, 2003 at 15:36 UTC | |
|
Re: Getopt::Auto question
by talexb (Chancellor) on Feb 21, 2003 at 16:07 UTC |