in reply to Backtracking for substitutions

my @lines = ( 'Bob Smith bsmith 00001234567 01/01/1986 00:00:00', 'Mary Ann Doe mdoe 00001234568 01/01/1986 00:00:00 00001 +234563 01/01/1986 00:00:00', 'Gilligan Q Smith gsmith 00001234569 01/01/1986 00:00:00 +'); foreach $line (@lines){ $data = $line; $line =~ s/^(\D+)(.*)/$1/; $data =~ s/^(\D+)(.*)/$2/; $data =~ s/(\d+)\s(\w+)\s(\w+)/$line,$1,$2,$3,\n/g }
This is still abit rough around the edges but I hope you will get the idea. I took the original question to mean that he wanted extra tokens identifiable on seperate lines in a csv format. So Mary would end up having two lines in the final output. What I tried to do was store the alpha text, identify the data, break the data down into 'sets' and finish it up by attaching the alpha text and delimiting it.
Now that i think about it, would a \w pickup slashes and colons? Maybe it needs an '|' in there also:P