in reply to How to capture quantified repeats?

After reading other responses and your replies, I offer two solutions:
  1. Text::CSV and its ilk - You are dealing with large delimited data files, so why not use a module designed to handle those?
  2. If you have a line in memory and you know you want to get the 1st, 4th and 5th terms, why not just grab those terms?

    #!/usr/bin/perl use strict; use warnings; my $ham = "spam\tspam\tspam\t\tyam\tclam"; my @jam; for my $i (0, 3, 4) { push @jam, $ham =~ /(?:[^\t]*\t){$i}([^\t]*)/; } print join("\n", '**', @jam, '**', '');

    You could even code that into a single expression if you only wanted to run it once.