my $date = '20080501'; $date =~ s/^(\d{4})(\d{2})(\d{2})$/$1-$2-$3/;