in reply to reading a log file and sorting by last name

Sorry, I forgot to show an example of the print out expected.
Bird Big 10 20 40 50 Klein Calvin 45 30 100 80 10 Nature Mother 100 100 23
I guess my example wasn't that good since apparently it was already alphabetized, but you get the idea. There can be any number of numbers at the end in which do NOT need to be sorted.

Also, in the first commented out split attempt, it was originally \s+\ instead of \w+\.

Replies are listed 'Best First'.
Re^2: reading a log file and sorting by last name
by jwkrahn (Abbot) on Oct 09, 2006 at 16:06 UTC
    If you just want to swap the first and second fields then:
    open (LOG, $log) or die "Error: $!"; print sort map { s/(\S+)(\s+)(\S+)/$3$2$1/; $_ } <LOG>;