#!/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 ;
阅读(1760) | 评论(0) | 转发(0) |