in reply to reading from file

On a command line, do a
perl -lane 'print "@F[0,2..$#F-2,$#F]"' input
if your file is 'input'. If its a windows system, do a
perl -lane "print qq{@F[0,2..$#F-2,$#F]}" input
instead.

Regards

mwa

Replies are listed 'Best First'.
Re^2: reading from file
by CountZero (Bishop) on Oct 10, 2007 at 08:56 UTC
    Very nice trick this 2..$#F-2 to deal with the variable number of fields in the input!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James