$ perl -wE 'my $x = q{Some Text ABCD ...}; $x =~ s/(\s*)/q{} . q{ } x length($1)/eg; say $x' Some Text ABCD ...