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\n");
 
 

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.

Getopt::Long - Extended processing of command line options的更多相关文章

  1. getopt--parse command line options

    getopt解析命令行选项 getopt, getopt_long, getopt_long_only, optarg, optind, opterr, optopt - Parse command- ...

  2. IAR Build from the command line 环境变量设置

    http://supp.iar.com/Support/?Note=47884 Technical Note 47884 Build from the command line The alterna ...

  3. An annotation based command line parser

    Java命令行选项解析之Commons-CLI & Args4J & JCommander http://rensanning.iteye.com/blog/2161201 JComm ...

  4. List of Chromium Command Line Switches(命令行开关集)——官方指定命令行更新网址

    转自:http://peter.sh/experiments/chromium-command-line-switches/ There are lots of command lines which ...

  5. Cookies with curl the command line tool

    w https://curl.haxx.se/docs/http-cookies.html curl has a full cookie "engine" built in. If ...

  6. Linux command line exercises for NGS data processing

    by Umer Zeeshan Ijaz The purpose of this tutorial is to introduce students to the frequently used to ...

  7. C++: Command Line Processing

    Save this code here for studying and using it. Surce code is here. CmdLine.h File #pragma once #incl ...

  8. [笔记]The Linux command line

    Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...

  9. Yandex Big Data Essentials Week1 Unix Command Line Interface Processes managing

    free displays the total amount of free and used memory free [options] top provides a dynamic real-ti ...

随机推荐

  1. mybatis(二):缘由

    本是Apache的一个开源项目iBatis 2010年,iBatis由Apache Software Foundation(软件基金会)迁移到了Google Code(代码托管平台),并改名为MyBa ...

  2. [P4550] 收集邮票 - 概率期望,dp

    套路性地倒过来考虑,设\(f[i]\)表示拥有了\(i\)种票子时还需要多少次购买,\(g[i]\)表示还需要多少钱 推\(g[i]\)递推式时注意把代价倒过来(反正总数一定,从顺序第\(1\)张开始 ...

  3. Learn from Niu 2020.1.13

    观念: 1. 把可视化的东西拾起来, 毕竟是做那个出身的. 2. 可视化里面时序数据,时空数据一直都是非常重要的. 3. know your data永远是最重要的一步, 我想更好的方式是,数据驱动, ...

  4. Autocorrelation in Time Series Data

    Why Time Series Data Is Unique A time series is a series of data points indexed in time. The fact th ...

  5. python之pandas简介

    一. Pandas简介 1.Python Data Analysis Library 或 pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的.Pandas 纳入了大量库和 ...

  6. POJ3122 Pie(二分)

    题目链接:http://poj.org/problem?id=3122 题意:一堆人分蛋糕,每人蛋糕大小一样,求最大能分多少,蛋糕必须是整块整块的,不能两块拼一起.然后注意输入F个人最后要分F+1份. ...

  7. 2、Spring-RootApplicationContext-refresh

    上一篇文中提到父容器root applicationContext最后是调用XmlWebApplicationContext去实现的, 但是什么时候开始解析标签(默认标签.自定义标签).注册bean以 ...

  8. GitBook相关使用以及配置笔记

    本地安装 GitBook的安装非常简单.您的系统只需满足这两个要求: NodeJS(推荐使用v4.0.0及以上版本) Windows,Linux,Unix或Mac OS X gitbook-cli 是 ...

  9. unity命令行参数

    Typically, Unity will be launched by double-clicking its icon from the desktop but it is also possib ...

  10. java项目中的异常处理总结

    异常指的是运行期出现的错误,也就是当程序开始执行以后执行期出现的错误.出现错误时观察错误的名字和行号最为重要. 比如你读取的文件不存在,数组越界,进行除法时,除数为0等都会导致异常. 我找一个比较形象 ...