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 deletedI 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
slightly grating.my $dir = $entry; open(FILE, "> $dir") or die "Can't open file, $dir: $!";
It's little things like that which make maintenance programmers go insane :-)my $file = $entry; open(FILE, "> $file") or die "Can't open file, $file: $!";
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.
In reply to Re: Re: Some problems with my code - Help...
by BazB
in thread Some problems with my code - Help...
by star7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |