in reply to RE: (Ovid) Re: Transpose some spaces to commas in a string
in thread Transpose some spaces to commas in a string
And a fairly simple regex can insert your commas. Re-reverse your result, and there you go.
Update: here's my attempt that appears to do what you want:
#!/usr/bin/perl -w use strict; my $test="Bob Q Smith bsmith 00001234567 5/1/00 12:00:00"; $test = reverse $test; #documenting the simple but nasty looking regex is left as an exercise + for the reader $test=~s/([:\d]+)\s([\d\/]+)\s([\d]+)\s([\w]+)\s(.*)/$1,$2,$3,$4,$5/ o +r die "Pattern didn't match: $test"; $test = reverse $test; print $test;
|
|---|