Otherwise, once I add "else" option at the last of "switch" statement its look not working for any options. Its look like the program will be pass to else fucntion, as examlple :my $opt = 'ah1:2:3:f:l:L:i:d:'; my ($isascii, $fmtfile, $fldname, $length, $location, $infile, $dirnam +e); getopts ("$opt", \%opt); switch ($_) { case {$opt{1}} { read_structure_type1($opt{1}); next; } case {$opt{2}} { read_structure_type2($opt{2}); next; } case {$opt{3}} { read_structure_type3($opt{3}); next; } case {$opt{f}} { $fldname = $opt{f}; next; } case {$opt{l}} { $length = $opt{l}; next; } case {$opt{L}} { $location = $opt{L}; next; } case {$opt{i}} { $infile = $opt{i}; next; } case {$opt{d}} { $dirname = $opt{d}; next; } case {$opt{h}} { usage(); exit; } }
switch ($_) { case {$opt{1}} { read_structure_type1($opt{1}); next; } case {$opt{2}} { read_structure_type2($opt{2}); next; } case {$opt{3}} { read_structure_type3($opt{3}); next; } case {$opt{f}} { $fldname = $opt{f}; next; } case {$opt{l}} { $length = $opt{l}; next; } case {$opt{L}} { $location = $opt{L}; next; } case {$opt{i}} { $infile = $opt{i}; next; } case {$opt{d}} { $dirname = $opt{d}; next; } else {usage(); exit; } }
In reply to Need help: Getopt by bh_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |