Hi, i have this piece of code
Getopt::Long::GetOptions ( 'u=s' => \$user, 'p=s' => \$passwd, 's=s' => sub { local *_ = \$_[1]; /^([^:]+):(\d+)$/ or die("Invalid format for option s.\n"); $host = $1; $port = $2;}, 'h=s' => \error_detect("h"), ) or error_detect("3 Invalid commmand line options.");
now the problem with this code is that no matter i type -h on the command prompt or not the routine error_detect is still called
i have tried to check all the documentation of getopt::long on cpan but there is nothing of the sort which tells me how to make a switch optional in Getopt::long.
like in GetOpt::STD we can make a switch optional by just typing a semi colon which makes that particular switch optional.
also i would like to know how do i ignore all the rest of the switches if -h is typed.
so basically i want to know two things
how do i make -h an optional switch in Getopt::long( just like we have a semi colon in STD)
if -h is typed on the command promot the Getopt::Long should ignore all the rest of the switches. ( in any case if -h is typed the user wont be typing the rest of the switches so the module shoulndnt give an error on that)
Thanks for giving me time.

In reply to how to make -h optional in GetOpt::Long by bahadur

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.