Re: open files.

BeHealthy@xxxxxxxxx wrote:
> If I use open(fp, $FILENAME), where $FILENAME contains some
> subdirectory that hasn't been set up yet, then it fails.

open() is not used for directories, it is used for files.
perhaps you're thinking of 'opendir()'?

> Is there any
> way I can get around this by letting the program to create the
> subdirectory if needed?

Your algorithm needs some rethinking. You're opening a directory. If
you want to use an analogy to opening files, you're opening the
directory "for reading". There is no such thing as opening a directory
"for writing". If the directory doesn't exist, even if there were a
built-in way to make open auto-create the directory, it would be
created empty. You would then have nothing to read from it.

It's time for you to tell us what you're *actually* trying to
accomplish, rather than ask for help with the method you've already
decided to use to accomplish this unknown goal.

FWIW, I don't see any particular reason you can't just do:
-d $directory_name or mkdir $directory_name
or die "Couldn't create directory $directory_name: $!\n";

(with the possible exception of the chance of a race condition)

Paul Lalli