Hello, I suggest this: #!/usr/bin/perl -w use strict;
my $var1 = "23456789"; my $var2; ($var2 = $var1) =~ s/(\d)/$1 /g; # only add 'g' for global substitution print "var1 = '$var1', var2 = '$var2'\n"; Regards. Paul Murphy a écrit : > > Hello, this is a two part question: a how to, and a how best to. > > I have a string of numbers: > > "2329238023089823" > > And I want insert a space after each number. I can see how to insert > after the first: > > s/(\d)/$1 / > > Can any one tell me how I can get the regexp to continue through the > string and insert spaces throughout? > > The next part of the question is, given the above string, what is the > best way of displaying the string with the added spaces, without > necessarily altering it in the variable? > > So if the first part of the question is answered, then that is one way of > doing it, but are there better ways (there are *always* better ways :-) )? > > Thanks, > > Paul. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]