in reply to Re: Getopt question again
in thread Getopt question again
!/usr/bin/perl -w use strict; use diagnostics; use Getopt::Long; my ($server, $proc, $prog); sub usage { print "this is wrong\n"; exit 0; } sub san_check_arg { usage () if $#ARGV != 0; if (defined($server)) { return ($server); } elsif (defined($proc && $prog)) { return ($proc,$prog); } else { usage(); } } my $val1 = eval { GetOptions ( "help" => sub { usage() }, "server=s" => \$server, "process=s" => \$proc, "program=s" => \$prog )}; die usage() if $@; #alone if (!$val1) { usage(); } my @ar = san_check_arg(); #check users input sanity print "@ar\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Getopt question again
by convenientstore (Pilgrim) on Jan 28, 2008 at 01:42 UTC | |
by graff (Chancellor) on Jan 28, 2008 at 04:55 UTC | |
by convenientstore (Pilgrim) on Jan 28, 2008 at 06:01 UTC | |
by convenientstore (Pilgrim) on Jan 29, 2008 at 03:58 UTC |