zoukankan      html  css  js  c++  java
  • Getopt::Long

    use Getopt::Long;

    my $data   = "file.dat";
    my $length = 24;
    my $verbose;
    GetOptions ("length=i" => $length,    # numeric
                "file=s"   => $data,      # string
                "verbose"  => $verbose)   # flag
    or die("Error in command line arguments ");
     
     

    DESCRIPTION

    The Getopt::Long module implements an extended getopt function called GetOptions(). It parses the command line from @ARGV, recognizing and removing specified options and their possible values.

    my $verbose = '';   # option variable with default value (false)

    my $all = '';       # option variable with default value (false)
    GetOptions ('verbose' => $verbose, 'all' => $all);


    The option name as specified to the GetOptions() function is called the option specification. Later we'll see that this specification can contain more than just the option name. The reference to the variable is called the option destination.
    The call to GetOptions() parses the command line arguments that are present in @ARGV and sets the option variable to the value 1 if the option did occur on the command line. Otherwise, the option variable is not touched. Setting the option value to true is often called enabling the option.

    GetOptions() will return a true value if the command line could be processed successfully. Otherwise, it will write error messages using die() and warn(), and return a false result.

  • 相关阅读:
    重学Java 面向对象 之 final
    java并发学习04---Future模式
    java并发学习03---CountDownLatch 和 CyclicBarrier
    java并发学习02---ReadWriteLock 读写锁
    java并发学习01 --- Reentrantlock 和 Condition
    链表的倒数第k个节点
    重建二叉树
    java并发学习--线程池(一)
    二叉树的深度
    vue-常用指令(v-for)
  • 原文地址:https://www.cnblogs.com/lelin/p/11289604.html
Copyright © 2011-2022 走看看