open(my $fh, '<', "input.txt") or die $!; and for writing: open(my $fh, '>', "output.txt") or die $!;