Submitted by alvin on August 9, 2009 - 8:41pm
tags: args arguments argv command line perl perl read source code
Perl command line FAQ: How do I read command-line arguments with Perl (command line args)?
Answer: With Perl, command-line arguments are stored in the array named @ARGV.
$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.
$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.
Example Perl command line arguments program
Here's a simple Perl program that prints the number of command-line arguments it's given, and the values of the arguments:
#!/usr/bin/perl
#---------------------#
# PROGRAM: argv.pl #
#---------------------#
$numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments.\n";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]\n";
}
分享到:
相关推荐
关于网络中端到端设计的一篇很好的论文~~~大家可以轻松获得
计算机网络中端到端论点的经典论文 作者:J.H. Saltzer, D.P. Reed and D.D. Clark M.I.T. Laboratory for Computer Science
The scripts range in complexity from one-line commands, to full-blown scripts with managed output and command-line arguments - examples that are applicable to all skill levels. Includes a companion ...
The scripts range in complexity from one-line commands, to full-blown scripts with managed output and command-line arguments examples that are applicable to all skill levels. Includes a companion CD ...
一个库,用于简化为用 Java 编写的工具定义、解析和实现命令行选项的枯燥任务。 该库简单而强大,足以快速处理常见的处理案例。
This is a library for parsing command-line arguments. It can parse both options and positional arguments. It aims to be easy to use and concise yet powerful and robust. Overview Defining options and ...
04-Variadic Arguments.rar
Command-Line-Interpreter-CLI:in用C ++制作的命令行解释器,它支持quit,remove,rename,rmdir,echo,out,zip,unzip等命令
Some advanced features of C such as memory models, command-line arguments, and bitwise operators have also been included. Case studies demonstrating the use of C in solving mathematical as well as ...
the child except via command-line arguments and environment variables, nor any way for the child to communicate with the parent except via the child’s exit status. None of these mechanisms provides ...
命令行解析系统。 通过Java Reflection,它允许简单的用法。 键被定义为标准的、可重载的方法,并由引擎透明地管理。 无需使用库定义的对象或枚举。 开发商有实力!
Command-line arguments: -os win32 -ws win32 -arch x86 Error Fri Mar 11 10:26:49 CST 2011 Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder! 出现这样的错误,可能是没...
and loaders, and provides an exhaustive coverage of concepts such as data types, control statements, arrays, strings, functions, pointers, structures, file systems, and command-line arguments....
查看两种处理控制台应用程序的命令行参数的方法手动解析system.commandline.dragonfruit
网络组成原理经典论文阅读报告,这篇论文提出了一个分布式计算机系统功能连接的端到端设计原则。作者提出,在底层的网络传输系统中进行复杂的工作将会使得整个系统效率低下。不如让底层网络传输只专心进行数据传输,...
Command-line Arguments Pointers to Functions Complicated Declarations Chapter 6: Structures Basics of Structures Structures and Functions Arrays of Structures Pointers to Structures Self-...
Some advanced features of C such as memory models, command-line arguments, and bitwise operators have also been included. Case studies demonstrating the use of C in solving mathematical as well as ...
When using the svn program, subcommands and other non-option arguments must appear in a specified order on the command line. Options, on the other hand, may appear anywhere on the command line (after ...
前端开源库-arguments-extended参数扩展,用于处理参数对象的实用程序