@ARGV:perl命令行参数
perl my.pl $ARGV[0] $ARGV[1]
看一个具体例子:
比如文件1的内容:
1320238
1320239
1320239
1320238
1320238
1320238
1320235
1320237
文件2的内容:
102 5709072117805887 4001 1301854
102 5709072117807510 4001 1320292
102 5709072117838653 4001 1301857
102 5709072117814280 4001 1305832
102 5709072117839397 4001 1310673
102 5709072117839335 4001 1311270
我想先把文件1的内容读取出来,然后读取文件二的内容,在读取文件2的内容的时候,文件2的最后一列需要包含在上文件1内。
[root@localhost ~]$ perl ex.pl 1.txt 2.txt
[root@localhost ~]$ cat ex.pl
#!/usr/bin/perl
use strict;
open(ONE,"$ARGV[0]") or die $!;
open(TWO,"$ARGV[1]") or die $!;
my %hash;
while (<TWO>) {
chomp;
my @line=split;
my $column4=$line[3];
$hash{$column4}=$_;
}
while (<ONE>) {
chomp;
print $hash{$_} if defined $hash{$_};
}
print"\n";
@ARGV:perl命令行参数相关推荐
- linux下perl命令行参数,Perl One-Liners | Perl命令行学习1 -e参数
注:本内容需要点的perl编程基础,最好是读过<perl语言入门>. 本系列是自己平常学习工作中的总结,每一个实例均为我为了讲解而设置的,自己试过的,如有错误,望能见谅 Perl 命令行参 ...
- perl 命令行备注
参考链接 Perl 常用命令行选项 unix 常用命令 perl 实现 sed awk tr nl perl 和sed,awk,tr,grep,nl等常用命令替换 sed task sed perl ...
- python3 命令行参数
Python有几种使用命令行参数的方法,这里介绍一种最基本的. 用 sys 的 sys.argv 来获取命令行参数: sys.argv 是命令行参数列表. len(sys.argv) 是命令行参数个数 ...
- python 命令行参数-python中命令行参数
python中有一个模块sys,sys.argv这个属性提供了对命令行参数的访问.命令行参数是调用某个程序时除程序名外的其他参数. sys.argv是命令行参数的列表 len(sys.argv)是命令 ...
- python 命令行参数-Python3 命令行参数
Python3 命令行参数 Python 提供了 getopt 模块来获取命令行参数. $ python test.py arg1 arg2 arg3 Python 中也可以所用 sys 的 sys. ...
- python菜鸟教程h-Python 命令行参数
Python 命令行参数 Python 提供了 getopt 模块来获取命令行参数. $ python test.py arg1 arg2 arg3 Python 中也可以使用 sys 的 sys.a ...
- Python 命令行参数
概述 Python 提供了 getopt 模块来获取命令行参数. $ python test.py arg1 arg2 arg3 Python 中也可以所用 sys 的 sys.argv 来获取命令行 ...
- 传递命令行参数示例代码 (C 和 Python)
C语言 在 C 语言中, 使用 main 函数的输入参数 argc 和 argv 传入命令行参数. argc 为 int 类型, 表示传入命令行参数的个数 (argument count); argv ...
- python中的命令行参数_python学习笔记6:命令行参数
1. 使用步骤 使用步骤如下: # 导入模块 import argparse # 获取parser, description文本会显示在help信息中 parser = argparse.Argume ...
最新文章
- 不允许使用不完整的类型解决方法
- freemarker程序开发
- gd动态曲线 php_PHP用GD实现折线图
- define宏定义和const定义之间的区别
- ehviewer苹果版下载_苹果用户:支持ios的云手机有没有?在哪里下载云手机ios版?...
- n个台阶,一个人每次最多走m步,算法实现
- kakfa学习教程一
- 判别式模型 vs. 生成式模型
- 学习OpenCV(2)OpenCV初探-2
- html 里面的 role 属性是什么意思和用途
- 微信小程序之使用云存储
- 【Linux_02】
- 安卓自动化工具:解锁屏幕+打开支付宝蚂蚁森林+收取能量+种树浇水+自动退出
- QCharts随时间流逝
- 查看用友NC的版本方法(不启动NC,只看NCHOME)
- 计算机word安装程序,word2007电脑版安装包
- Linux配置阿里云DNS
- 关于 ARAS PLM (一) 部署
- 用于土地使用和土地覆盖分类的landsat8的OLI波段组合的选择
- Directshow获取高帧率无驱摄像头