in reply to can't open a file?
open(my $fh, '<', "input.txt") or die $!; and for writing: open(my $fh, '>', "output.txt") or die $!; [download]
use autodie;