perl - Getopt::Long multiple switches -


i have 3 methods , 2 switches

i

  • methoda run if switcha set
  • methodb run if switcha , switchb set
  • methodc run if switcha , switchb set , arguement switchb produced

like so

./main --switcha ./main --switcha --switchb ./main --switcha --switchb hello 

my code

my $result = getoptions{              "switcha" => \$opt_a,              "switchb:s" => \$opt_b    };    methoda if($opt_a);  methodb if($opt_a && $opt_b eq "");  methodc if($opt_a && $opt_b ne "") 

i have tried different things essentially, if want methodb run, method runs, , if want methodb run, methoda runs.

haven't got round testing methodc yet.

any help?

methoda if $opt_a && !defined($opt_b); methodb if $opt_a && defined($opt_b) && $opt_b eq ""; methodc if $opt_a && defined($opt_b) && $opt_b ne ""; 

or

if ($opt_a) {    if (defined($opt_b)) {       if ($opt_b eq "") {          methodb       } else {          methodc       }    } else {       methoda    } } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -