怎么从 2007-10-31 18:19:55 以这个格式取出 20071031

怎么从 2007-10-31 18:19:55 以这个格式取出 20071031

从 2007-10-31 18:19:55  以这个格式取出 20071031

2007-10-31 18:19:55  是个变量


已解决

my $date_time="2007-10-31 18:19:55";
my $date;
my $year=substr($date_time,0,4);
my $month=substr($date_time,5,2);
my $day=substr($date_time,8,2);
$date=$year.$month.$day;

$date =~ s/(\d{4})-(\d{2})-(\d{2})\s*(\d{2}):(\d{2}):(\d{2})/$1$2$3/;
my @m = split /[\-\s:]+/, $_[0];