in reply to while loop over filehandle

As far as I can tell, your code should work, but it's not very Perlish. You can easily lose the loop control variable there and clarify the happenings. chomp can remove the end-of-lines on an entire list at once. join is ideal for concatenating a list of strings. In all, I'd write this like so:
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.