open(INPUT,$file) or die ("Error opening '$file' for input: $!\n"); open(OUTPUT,">".$file) or die ("Error opening '$file' for output: $!\n"); while(read(INPUT,$buf,8192)) { print OUTPUT $buf; } close(INPUT) or die "Couldn't close '$file' after input: $!\n"; close(OUTPUT) or die "Couldn't close '$file' after output: $!\n";