On Mon, Jul 22, 2002 at 02:41:25PM -0400, Aaron J Mackey wrote: > > I can't seem to get this any shorter: I want the second through the > next-to-last elements of @F joined by " ", and then the last item of @F. > > perl -ape '$,=" ";s//>@F[1..$#F-1]\n$F[$#F]/' > > or (no join, but same general idea): > > perl -pe 's/\s+(\S+)$/\n$1/;s/^\S+\s+/>/;' > > What trick am I missing?
Your regexes are unnecessarily verbose. :) perl -pe 's/\S+$/\n$&/;s/\S+\s+/>/' Ronald
