#!/usr/bin/perl use warnings; use strict; open( my $output, '>', '/tmp/output.txt' ) or die "Error: Cannot open the file - $!\n"; open( my $input, '<', '/tmp/input.txt' ) or die "Error: Cannot open the file - $!\n"; print {$output} while (<$input>); ## This is were the problem is. close( $input ); close( $output );