[Perl]根据当前时间来创建文件夹
发布时间:2020-12-15 23:42:46 所属栏目:大数据 来源:网络整理
导读:根据当前时间来创建文件夹 执行以下code 后,会在脚本所在目录下创建一个文件夹,格式如:user_xxxxxxxx_xxxxxx_hello #!/usr/bin/perl use strict; sub mkdir_by_date{ #print local time my ( $sec , $min , $hour , $mday , $mon , $year , $wday , $yday
根据当前时间来创建文件夹执行以下code 后,会在脚本所在目录下创建一个文件夹,格式如:user_xxxxxxxx_xxxxxx_hello #!/usr/bin/perl
use 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,$sec);
printf("DateTime: %s",$mytime);
system("mkdir user_${mytime}_hello");
}
mkdir_by_date;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |