in reply to RE (tilly) 1: Merging files
in thread Merging files

Oooh.. I like that. Here's another tack at that last bit of code, that'll probably be more memory efficient in the long run:
while (@handles) { @handles = grep { if (defined(my $line = readline($_))) { print $line; 1; } else { 0 } } @handles; }
The advantage here is that we're rewriting @handles in one fell swoop in the fairly strongly optimized grep operation, not constantly shifting and pushing on an array that will just keep wandering through higher and higher memory. {grin}

-- Randal L. Schwartz, Perl hacker