Chinaunix首页 | 论坛 | 博客
  • 博客访问: 359107
  • 博文数量: 35
  • 博客积分: 2176
  • 博客等级: 大尉
  • 技术积分: 797
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-13 14:03
文章分类

全部博文(35)

文章存档

2012年(9)

2009年(14)

2008年(12)

我的朋友

分类:

2009-09-23 12:01:30

#!/usr/bin/perl

# delete the line number mark of lines in a code scource file

if($#ARGV != 1){
print "ERROR: Bad arguments ! \n";
print "USAGE: delnum.pl sourceFileName NewFileName\n";
exit 1;
}

$oldfile = $ARGV[0];
open OLDFILE , "<./$oldfile"
or die "Cannot open file $oldfile $!";

@lines=();

$newfile = $ARGV[1];
open NEWFILE , ">./$newfile"
or die "Cannot create file $newfile $!";
foreach(@lines){
$_=~s/^\d+\s?//;#正则表达式,把行首的数字替换为空字符,即去掉
print NEWFILE "$_";
}
close OLDFILE ;
close NEWFILE ;
阅读(1732) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~