Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    Getopt::Popt 0.02

    Download button

    No screenshots available
    Downloads: 355  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    James Baker | More programs
    Perl Artistic License / FREE
    March 8th, 2007, 05:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Getopt::Popt description

    Getopt::Popt is a Perl interface to the popt(3) library.

    Getopt::Popt is a Perl interface to the popt(3) library.

    SYNOPSIS

    use Getopt::Popt qw(:all);

    # setup the options array
    push @options,new Getopt::Popt::Option(
    longName => "long",
    shortName => "l",
    argInfo => POPT_ARG_STRING,
    arg => $qux,
    val => $val);

    # or, if you're lazy, have Getopt::Popt automagically do the new()
    push @options, { shortName => 's',
    argInfo => POPT_ARG_NONE,
    arg => $quux,
    val => 's'
    };

    # "val"s can be a single character or an integer:
    push @options, { longName => 'xor',
    argInfo => POPT_ARG_VAL | POPT_ARGFLAG_XOR,
    arg => $quuux,
    val => 0xbadf00d # integer
    },
    Enable automatic help/usage messages (--help or --usage):
    push @options, POPT_AUTOHELP;
    Create a new popt context:
    $popt = new Getopt::Popt(name => $alias_name,
    argv => @ARGV,
    options => @options,
    flags => $flags);
    Setup option aliases:
    # load some aliases
    $popt->readDefaultConfig();
    $popt->readConfigFile("/path/to/aliases");

    # add your own alias
    $alias = new Getopt::Popt::Alias(longName => "taco",
    argv => [qw(--flavored --kisses)]);
    $popt->addAlias($alias, $alias_flags);
    Load options as you would in C:
    # loop through the options, using the popt C way:
    while(($rc = $popt->getNextOpt()) > 0) {
    ...
    # one way to get the arg val
    $bork = $popt->getOptArg();
    ...
    # stuff some args
    $popt->stuffArgs(qw(-q -u -x));
    ...
    # start over
    $popt->resetContext();
    ...
    }
    And handle errors as you would in C:
    $errstr = $popt->strerror($rc);
    $badopt = $popt->badOption($rc,$badopt_flags);
    Or try the new perly way:
    eval {
    while(defined($val = $popt->getNextOptChar())) {
    ^^^^-- note!
    # $val is a Scalar::Util::dualvar:
    if($val eq "c") { # getArgs();

    Product's homepage

      


    TAGS:

    Perl interface | popt library | Perl module | Getopt::Popt | popt | library

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM