in reply to RE: (Ovid) Re: Transpose some spaces to commas in a string
in thread Transpose some spaces to commas in a string

Offhand, I'd say try the FAQ about putting commas into a number. If the variable mess is at the start of your string, reverse it.
Bob Q Smith bsmith 00001234567 5/1/00 12:00:00
becomes
00:00:21 00/1/5 76543210000 htimsb htimS Q boB

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;