in reply to Merging 3 files

Why woldn't you just do something like the following (untested, sorry):
#!perl use strict; use warnings; my @handles; my $i = 0; for (@ARGV) { open $handles[$i++], '<', $_ or die "Failed to open $_: $!\n"; } my $line; $i = 0; while (1) { $line = <$handles[$i]>; defined($line) or last; print $line; } continue { ++$i; $i %= @handles; } close $_ for @handles;

Hope this helped.
CombatSquirrel.

Update: Closed files. Thanks to b10m.
Entropy is the tendency of everything going to hell.