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. C++查看大端小端模式

    在学习计算机组成原理的时候,看到大端小端模式,便想实验一下,首先介绍一下 C 中的union,这个平时用得少,估计在单片机这种可能会运用,在平时写代码的时候几乎是用不着union的. union:联合 ...

  2. 01:认识QT

    Qt: Qt是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架.它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器.Qt是面向对象的框架,使用特 ...

  3. set的使用

    集合是Python的一种数据类型,集合是一个可变容器.常用于列表的去重. 什么是集合 集合是一个可变容器 集合中的数据对象都是唯一的(不可重复) 集合是无序的存储结构 集合是可迭代对象 集合内的元素是 ...

  4. 二分-B - Dating with girls(1)

    B - Dating with girls(1) Everyone in the HDU knows that the number of boys is larger than the number ...

  5. Python之二:基础知识

    1.常量: 1.1.数:5.1.23.9.25e-3 4种类型的数——整数.长整数.浮点数和复数 2是一个整数的例子. 长整数不过是大一些的整数. 3.23和52.3E-4是浮点数的例子.E标记表示1 ...

  6. C语言strcat()函数:字符串连接(拼接)

    C语言strcat()函数:字符串连接(拼接)   C语言 strcat() 函数用来将两个字符串连接(拼接)起来. 头文件:string.h 语法/原型: char*strcat(char* str ...

  7. 注册登录于一体的 用户登录注册界面(php)

    <!DOCTYPE HTML><html> <head> <script type="text/javascript" src=" ...

  8. 一次 utf-8 bom引起的问题

    同事代码新增加了功能,推到服务器上,意外导致登录失败,回退到之前的版本上,可以正常使用. 这次只上传了 route.php 文件,系统登录失败. 随后使用kdiff3对比了两版本的route.php文 ...

  9. [CF]Round 516

    A Make a triangle! 题意:给定三根线段,问最少要延长多少才能拼成一个三角形. 数学题. B Equations of Mathematical Magic 题意:求$a - (a \ ...

  10. Spring Cloud介绍

    Spring Cloud中国社区博客 Spring Cloud发展到2016年,国内关注的人越来越多,但是相应学习交流的平台和材料比较分散,不利于学习交流,因此Spring Cloud中国社区应运而生 ...