in reply to Refactor this to eliminate the duplicated printf?

Have not tried this, but I have run into this same thing. Took a look at List::MoreUtils and noticed the natatime EXPR, LIST which seems like it might do exactly what you want assuming you read your __DATA__ into an array. You did not specify whether or not the use of modules was ok for you, so I just assumed it was.

From the docs:

Example: my @x = ('a' .. 'g'); my $it = natatime 3, @x; while (my @vals = $it->()) { print "@vals\n"; } This prints a b c d e f g
Does that suit your requirements?

...the majority is always wrong, and always the last to know about it...

Insanity: Doing the same thing over and over again and expecting different results...

A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is a facct

Replies are listed 'Best First'.
Re^2: Refactor this to eliminate the duplicated printf?
by wanna_code_perl (Friar) on Jul 14, 2014 at 06:00 UTC

    Unfortunately, my input is streamed, and larger than available RAM. For certain smaller data sets, this would be a decent solution.