[Perl]根据当前时间来创建文件夹

来源:互联网 发布:淘宝人生免费txt下载 编辑:程序博客网 时间:2024/05/17 03:05

根据当前时间来创建文件夹

执行以下code 后,会在脚本所在目录下创建一个文件夹,格式如:user_xxxxxxxx_xxxxxx_hello

#!/usr/bin/perluse strict;sub mkdir_by_date{    #print local time    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);    my $mytime = sprintf("%04d%02d%02d_%02d%02d%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec);    printf("DateTime: %s", $mytime);    system("mkdir user_${mytime}_hello");}mkdir_by_date;
0 0
原创粉丝点击