in reply to Getopt::Long
Alternatively, i'd either use http://search.cpan.org/author/PRL/Term-Interact-0.44/Interact.pmuse Getopt::Long; use Data::Dumper; my %menu; my @root = ( \%menu, qw[add! remove! die! warn!] ); PROMPT: print "what u want(add remove die warn)?: "; while(<>){ chomp; $_ = "-$_" unless /^-/; # fake it local @ARGV = $_; undef %menu; if(GetOptions( @root )){ print "\n\n", Dumper \%menu; if(exists $menu{add}) { print "\n\nadding\n\n"; } elsif(exists $menu{remove}) { print "\n\nremoving\n\n"; } elsif(exists $menu{warn}) { warn "\n\nwarning\n\n"; } elsif(exists $menu{die}) { die "\n\ndying!\n\n"; } }else{ warn "\n\nerror parsing options [$!][$@]\n\n"; } goto PROMPT; } __END__
Also, i'd check out the Getopt distributions and see if any of the modules listed suit your needs.
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getopt::Long
by hotshot (Prior) on Dec 16, 2002 at 12:00 UTC |