in reply to Create file in a specified directory

You may want to use lexical scope in addition to strict, warnings, diagnistics
pragmas and the good advices already given:
open my $fh ...