while () { # Remove white space at end of line; s/\s+$//g; # Get length of line my $length = length; my @items = split; # If line is long, want the internal items, # if shorter want the last ones # 50 works with the example. if ( $length > 50 ) { print join( "\t", @items[ 1, $#items - 4, $#items - 3 ] ), "\n"; } else { print join( "\t", @items[ 1, $#items - 1, $#items ] ), "\n"; } } __DATA__ 605 abc xxx 410.00 mV < 450.98 mV < 490.00 mV 606 bcd yyy -46.50 dB < 50.70 dB 607 are zzz 50.00 dB < 58.48 dB