my $string = 'DD-MM-YYYY HH:MM::SS'; $string = sprintf '%s-%s-%s %s', (split /[- ]/, $string)[2,1,0,3];