open FILE, "file.txt" or die "Can't open file.txt:$!\n"; while(my $firstline = ) { $secondline = or die "Ran out of lines!\n"; # how to join the lines is left as an exercise for the # reader: hint ... Dot knows much. }