#!/usr/local/bin/perl
open (INFILE, "file1") ||
        die ("Can't open file1 for reading\n");
open (OUTFILE, ">file2") ||
        die ("Can't open file2 for writing\n");
# the following only works if file1 isn't too big
@contents = <INFILE>;
print OUTFILE (@contents);
# we don't really need the calls to close, but they
# make things a little clearer
close (INFILE);
close (OUTFILE);
open (INFILE, "file1") ||
        die ("Can't reopen file1 for reading\n");
open (OUTFILE, ">>file2") ||
        die ("Can't append to file2\n");
@contents = <INFILE>;
print OUTFILE (@contents);
