in reply to How to count the number of columns in a line
It looks like you're trying to scan columns 4 though the end of the line for a particular pattern for each line.
Perhaps this sorta golf-like snippet will help.
#!/usr/bin/perl use strict; use warnings; my $pattern = qr/[45fg]/; # Look for "4,5,f,g" while(<DATA>) { 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
Pax vobiscum,
-v.
|
|---|