# tested, but might not exactly match what anonymous # was doing (added newline output after each chunk, # blank after comma seperator,...) use constant CHUNK_SIZE => 20; open(FILE, $filename) or die "Can't open $filename: $!\n"; while() { s/\012(?:\015)?|\015(?:\012)?//g; push @users, $_; unless($. % CHUNK_SIZE) { print join(', ', @users), "\n"; @users = (); } } print join(', ', @users); # Output what's left. close FILE;