#!/usr/bin/perl #undef $/; #$/=''; my $N = qr{[A-Z]\w+}; while(<>){ chomp; s/(.*) ($N)$/$2, $1/; print "$_\n"; }