in reply to while loop over filehandle
use constant PER_LINE => 20; my @out; do { @out = (); while(<FILE>) { push @out, $_; last if not 1 .. PER_LINE; } chomp @out; print PIPE join ",", @out; print PIPE "\n" if @out; } until @out != PER_LINE;
See Mark-Jason Dominus' excellent Program Repair Shop and Red Flags article series on Perl.com for many introductory pointers on writing good code.
Update: D'oh! Fixed a tiny but nasty thinko in the code.
Makeshifts last the longest.
|
|---|