标题: [问题求助] Perl怎样修改日期时间格式? [打印本页]
作者: Perl 时间: 2011-12-23 22:44 标题: Perl怎样修改日期时间格式?
比如文本内容如下:
Dec 23 2011 22:41:46
希望改成:
2011-12-23 22:41:46
作者: sxw 时间: 2011-12-24 23:21
进行替换不行吗?
作者: lllsoslll 时间: 2012-10-19 00:25
- %months = (
- Jan => 0,
- Feb => 1,
- Mar => 2,
- Apr => 3,
- May => 4,
- Jun => 5,
- Jul => 6,
- Aug => 7,
- Sep => 8,
- Oct => 9,
- Nov => 10,
- Dec => 11,
- );
-
- while(<DATA>){
- ($m,$d,$y,$t) = /(\w+)\s(\d+)\s(\d+)\s(.*)/;
- print "$y-$months{$m}-$d $t\n";
- };
-
- __DATA__
- Dec 23 2011 22:41:46
- Dec 23 2011 22:33:46
- Aug 3 2012 22:41:46
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |