#!/usr/bin/perl use strict; use warnings; my $pattern = qr/[45fg]/; # Look for "4,5,f,g" while() { chomp, print "$_\n" for grep { /$pattern/ } ((split /\t/)[3 .. s/\t(?!\n)/\t/g ]); } __DATA__ 1 2 3 4 5 6 7 8 9 108 9 a b c d e f g h i j