my $string = '20050516'; my $newstring = substr($string,0,8). "!" . substr($string,0,4) . "!" . substr($string,8,0); print $newstring;