Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > 其他编程语言 > [Perl]实用性很强的模块Getopt::Std和Getopt::Long
【标  题】:[Perl]实用性很强的模块Getopt::Std和Getopt::Long
【关键字】:Perl,Getopt,Std,Getopt,Long
【来  源】:http://blog.chinaunix.net/article.php?articleId=50897&blogId=8897

[Perl]实用性很强的模块Getopt::Std和Getopt::Long

Your Ad Here

这两个模块能够很容易处理命令开关,以后就不用自己在程序中分析处理了。

这两个模块无需到CPAN下载,perl自带。

#!/usr/bin/perl -w
use Getopt::Std;
Getopt::Std::getopts('a:b:c:de', \%options);
print "-a:$options\n";
print "-b:$options\n";
print "-c:$options\n";
print "-d:$options\n";
print "-e:$options\n";

#!/usr/bin/perl
use Getopt::Long;
Getopt::Long::GetOptions(
                'page=i'    => $page,
                'onoff!'    => $onoff,
                'help'      => $wants_help,
                'name=s'    => $name,
                'number:i'  => $number);
if(defined($page)){
        print "page flag set to $page\n";
}
if(defined($onoff)){
        print "onoff flag set to $onoff\n";
}
if(defined($wants_help)){
        print "help flag set to $wants_help\n";
}
if(defined($name)){
        print "name flag set to $name\n";
}
if(defined($number)){
        print "number flag set to $number\n";
}

一个严格匹配ip地址的perl脚本:【上一篇】
曾经写过一个很粗糙的扫描程序(perl coded):【下一篇】
【相关文章】
  • 一个严格匹配ip地址的perl脚本
  • 用perl生成代理脚本
  • perl qq 模块Net::OICQ 0.98
  • Perl Cookbook 第二版
  • 终于开始写gtk2-perl教程
  • 向脚本传递参数-getopts
  • 想学perl,好难!
  • Perl 作为命令行实用程序(perl1line)
  • 用perl1line写的几个简单unix命令
  • 用perl写的一个脚本
  • 【随机文章】
  • 给页面减减肥!
  • 在JAVA应用程序中如何实现FTP的功能
  • 成为Eclipse热键高手
  • 仅需 RMB 49,999 的特惠捆绑价,可获 IBM DS300 优惠方案!
  • 用ParamArray接收任意个参数
  • 翻译:Effective C++, 3rd Edition, Item 32: 确保 public inheritance 模拟 "is-a"(上)
  • 在线备份服务费用需精打细算
  • ASP.net:Literal控件用法
  • 转:Gentoo的内核升级
  • 程序员的6种阶段
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.