2011年7月14日
摘要: 我们在linux常常用到一个程序需要加入参数,现在了解一下perl中的有关控制参数的函数.getopt.在linux有的参数有二种形式.一种是–help,另一种是-h.也就是-和–的分别.–表示完整参数.-表示简化参数.在perl中也分这二种.Getopt::Std模块的功能: 初始化perl命令行中所接受的参数,简化了命令行参数的解析。简化参数例子:12345678910#!/usr/bin/perl -wuse strict;use Getopt::Std;use vars qw($opt_a $opt_b $opt_c);getopts('a:b:c:');print & 阅读全文
posted @ 2011-07-14 17:05 香格里拉\(^o^)/ 阅读(7743) 评论(0) 推荐(0)
摘要: perl 中的vars是perl中的一个pragma(预编译指示符),专门用来预定义全局变量,这些预定义后的全局变量在qw()列表中,在整个引用perl文件中皆可使用,即便使用usestrict也不会报错:use strict ;$str = "hello world!\n" ;报错信息:Global symbol "$str" requires explicit package name at ~vars.pl line 3.Execution of ~vars.pl aborted due to complication errors.引用use v 阅读全文
posted @ 2011-07-14 16:22 香格里拉\(^o^)/ 阅读(1742) 评论(0) 推荐(0)