$x = sprintf "%02d\/%02d\/%04d\ %02d\:%02d", $MM +1 , $DD , $YY + 1900, $hh, $mm; $x =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; print $x;