my $zahl = 12345678; 1 while $zahl =~ s/(\d+)(\d{3})/$1 $2/; print $zahl;