在所有文件的第一行后添加一行注释,例如:
#!/usr/bin/perl
.....
....
.....
....
在其后面添加添加一行## Copyright (c) 2011 by mcshell
效果如下
#!/usr/bin/perl
## Copyright (c) 2011 by mcshell
...
...
## Copyright (c) 2011 by mcshell
...
...
完成代码如下
#!/usr/bin/perl
## Copyright (c) 2011 by mcshell
my %do_these;
foreach (@ARGV) {
$do_these{$_}=1;
}
while (<>){
if(/^## Copyright /){
delete $do_these{$ARGV}; #如果存在就删除它
}
}
@ARGV= sort keys %do_these;
$^I=".mc";
while (<>){
if(/^#!/){
$_ .= "## Copyright (c) 2011 by mcshell\n";
}
print;
}
## Copyright (c) 2011 by mcshell
my %do_these;
foreach (@ARGV) {
$do_these{$_}=1;
}
while (<>){
if(/^## Copyright /){
delete $do_these{$ARGV}; #如果存在就删除它
}
}
@ARGV= sort keys %do_these;
$^I=".mc";
while (<>){
if(/^#!/){
$_ .= "## Copyright (c) 2011 by mcshell\n";
}
print;
}
本文转自 mcshell 51CTO博客,原文链接:http://blog.51cto.com/mcshell/482156,如需转载请自行联系原作者