in reply to File creation script

If I get you right, you want to find out whether a file is a directory or just a file.

That is quite easy:

if (-d $filename) { ... }
More info about file tests like -d can be found in the perlfunc man page around line 147, at the beginning of the alphabetical listing of the functions