关闭

学习perl写的一个

标签: perlfilenamesdate
541人阅读 评论(0) 收藏 举报

#------------------------------------------------------------
# template.pl  Usage: template.pl [FILENAMES]
#------------------------------------------------------------
# TO :
#     Create Code Template
#     生成程序模板
#------------------------------------------------------------
# BY :
#     s91
#     s91.ctgu.cn@gmail.com
#------------------------------------------------------------
# PS :  
# Make sure that the files you want to create is not
# exist!enjoy it :)
#------------------------------------------------------------
# Date : 
#     2006.05.21
#------------------------------------------------------------
$t = @ARGV;
if ($t == 0)
{
 print "Usage: template.pl [FILENAMES]/n";
}
about();
foreach $s (@ARGV)
{
 @name = split //./,$s ;
 $ss = ">".$s;
 $l = @name;
 @name[$l-1]!~ tr/A-Z/a-z/;
 if ( @name[$l-1]eq"c"||@name[$l-1]eq"cpp"||@name[$l-1]eq"cc"||@name[$l-1]eq"h")
 {
  open(out,$ss)||die("Cannot Create files/n");
  print out ("/*");
  print out (("-")x57);
  print out ("*//");
  print out ("/n");
  print out ("#/n");
  print out ("# ");
  print out ($s);
  print out ("/n");
  print out ("#/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# TO : /n");
  print out (("#/n")x2);
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# BY : /n");
  print out ("#     s91/n");
  print out ("#     s91.ctgu.cn/@gmail.com/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# PS : /n");
  print out (("#/n")x2);
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("#/n");
  print out ("# Date :  ");
  print out (GetDate());
  print out ("/n");
  print out ("#/n");
  print out ("//*");
  print out (("-")x57);
  print out ("*//");

 }
 elsif(@name[$l-1]eq"pl"||@name[$l-1]eq"py")
 {
  open(out,$ss)||die("Cannot Create files/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# ");
  print out ($s);
  print out ("/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# TO : /n");
  print out (("#/n")x2);
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# BY : /n");
  print out ("#     s91/n");
  print out ("#     s91.ctgu.cn/@gmail.com/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# PS : /n");
  print out (("#/n")x2);
  print out ("#");
  print out (("-")x60);
  print out ("/n");
  print out ("# Date :  ");
  print out ("/n");
  print out ("#     ");
  print out (GetDate());
  print out ("/n");
  print out ("#");
  print out (("-")x60);
  print out ("/n");

 }
 else
 {
  print "sorry,you should create this filetype by yourself/n";
 }
 
}
sub about()
{
 print "//=-----------------------------------=//r/n";
 print "|     code template create by s91     |/r/n";
 print "|        s91.ctgu.cn/@gmail.com        |/r/n";
 print "/=-----------------------------------=///r/n";
}
sub GetDate()
{
 my($year,$mon,$day)=(localtime)[5,4,3];
 $year+=1900;
 $mon+=1;
 my $today=sprintf("%04u/.%02u/.%02u",$year,$mon,$day);
 return $today;
}
 ==============================

没有写好!

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:10296次
    • 积分:174
    • 等级:
    • 排名:千里之外
    • 原创:7篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档