#!/usr/bin/perl -w use strict; my ($string1, $string2); # read files in chunks instead of lines # remove if you realy want to read textfiles # line by line local $/ = \32768; # "block size" open (FILE1, "< x") || die "Cannot open file : $!"; open (FILE2, "< y") || die "Cannot open file : $!"; open (FILE3, "> z") || die "Cannot open file : $!"; # set binmode, so binary files don't get messed # up on systems with text/binary mode files # (like windows or MS-DOS) binmode (FILE1); binmode (FILE2); binmode (FILE3); print FILE3 , or die "Error concatenating: $!"; close FILE1 or die "Error closing x: $!"; close FILE2 or die "Error closing y: $!"; close FILE3 or die "Error closing z: $!";