Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1142796
  • 博文数量: 312
  • 博客积分: 12522
  • 博客等级: 上将
  • 技术积分: 3376
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-27 18:35
文章分类

全部博文(312)

文章存档

2016年(3)

2015年(1)

2013年(1)

2012年(28)

2011年(101)

2010年(72)

2009年(13)

2008年(93)

分类: Python/Ruby

2012-03-03 14:23:41

1>更新一个文件
将文件file.txt里的sina替换为google
1.文件file.txt
sina baidu sohu
sina youku sina
tudou qiyi leshi
 
2.hello.pl
 
#!/usr/bin/perl -w
use strict;
@ARGV="file.txt";
$^I=".bak";
while (<>) {
s/sina/google/;
print;
}
 
perl hello.pl
type file.txt
 
google baidu sohu
google youku sina
tudou qiyi leshi
2>一次更新多个文件
 
#!/usr/bin/perl -w
use strict;
@ARGV=glob "*.txt";
$^I=".bak";
while (<>) {
s/sina/google/;
print;
}
阅读(884) | 评论(0) | 转发(0) |
0

上一篇:Gerrit简易安装入门

下一篇:Git 常用命令

给主人留下些什么吧!~~