#!/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/ or die "Pattern didn't match: $test"; $test = reverse $test; print $test;