Hello! Sorry fro my English. :) I have the next program:
#!/usr/bin/perl use strict; use feature qw(say); use warnings; use utf8; use Getopt::Long; my ($helpCmdArgv, $configCmdArgv, $setupCmdArgv, $servertypeCmdArgv); my $cmdArgsResult; $cmdArgsResult = GetOptions ( "help" => \$helpCmdArgv, "config=s" => \$configCmdArgv, "setup" => \$setupCmdArgv, "servertype=s" => \$servertypeCmdArgv ); # Condition 1 if ( (@ARGV eq 0) or ($helpCmdArgv eq 1) ) { say scalar(@ARGV); &Help; }; # Condition 2 say scalar(@ARGV); ($configCmdArgv) ? say 'Custom config' : say 'Default config'; sub Help { print <<HELP; Avliable options: --config - Main config file --setup - Just install files. --servertype - Server type, where: |-> db - Database server; |-> app - Application server; HELP exit 1; };
I want run program with options --help and without options. In both cases i want that my programm show me HELP MESSAGE (see Condition 1). But i need aslo to set arguments like this  ./install.pl --config main.cfg --setup (see Condition 2). But this not work, because @ARGV always zero and "Condition 2" never to be. I read that GetOpt ignor (or replace) standart ARGV. You can suggest me check "--config" and "--setup" in the "Condition 1". But I would like to avoid it. How to check for "--config main.cfg" when the user can execute the program with an empty argument? Thanks.

In reply to GetOpt::Long empty ARGV by Pazitiff

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.