in reply to Re: Some problems with my code - Help...
in thread Some problems with my code - Help...

There is nothing wrong with open(FH, "> $file");

perldoc -f open says:

The filename passed to 2-argument (or 1-argument) form of open() will have leading and trailing whitespace deleted
I prefer to put some whitespace between the permissions operator and the filename, others do not. It's a style thing, but there is nothing wrong with it.

Preferably use warnings instead of perl -w. There is a thread here explaining why, but I can't track it down right now. See perldoc perllexwarn for more info.
You should consider using the strict pragma as well as the warnings pragma.

Another minor point - I personally find

my $dir = $entry; open(FILE, "> $dir") or die "Can't open file, $dir: $!";
slightly grating.
It's a file you want to create - I initially couldn't figure out if you really wanted opendir to open a directory handle, or if you wanted:
my $file = $entry; open(FILE, "> $file") or die "Can't open file, $file: $!";
It's little things like that which make maintenance programmers go insane :-)

As another poster has already pointed out, you can't go creating files, directories, pipes etc, in the same directory with the same name as an existing file/dir/pipe.


If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
That way everyone learns.