我想让我的脚本在内部跟踪他们的最后修订日期作为评论.这可能吗?在我看来,它需要获取日期,然后打开其脚本文件的附加,写入数据并保存文件.
感谢Everone,很棒的回答者.基于GreenMatt留下的代码片段,我把它扔到了一起......
#!/usr/bin/perl -w
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
$year += 1900;
$mon +=1;
open SELF, ">> letterhome.pl" or die "Unable to open self";
#print SELF "# ran/modified at " . join(' ', localtime(time)) . "\n";
print SELF "# ran/modified at $hour:$min:$sec on $mon/$mday/$year.\n";
close(SELF);
# ran/modified at 31 48 23 24 7 110 2 235 1
# unformated result of using localtime(time)
#Results using formated time/date
# ran/modified at 0:1:43 on 8/25/2010.
# ran/modified at 0:2:40 on 8/25/2010.
# …Run Code Online (Sandbox Code Playgroud) perl ×1