Try
do {
$artikelID = &newID;
} until (! -e $ARTIKEL_DIR.$artikelID);
open ($artikelID);
That checks for the existence of the file (-e).
John
-----Original Message-----
From: Martijn van Exel [mailto:[EMAIL PROTECTED]]
Sent: 21 September 2001 16:03
To: [EMAIL PROTECTED]
Subject: checking for existence of a file.
I have a subroutine &newID that constructs a pseudo-random ID on every
invocation. Regularly, a file needs to be created in a directory, say
$ARTIKEL_DIR, using a newly generated ID. Of course, I want to make sure
that the file (the ID) doesn't exist yet. Of course, I could put all IDs
previously generated in a kind of logfile and check that logfile. But
then I thought of this:
do {
$artikelID = &newID;
} until (!`$ARTIKEL_DIR.$artikelID`);
open ($artikelID);
Would that work at all? What I think it should do is: 'Create a fresh
pseudo-random ID, check if a file with that name exists in the directory
specified, if it does, try again, if not, open the (new) file.
Can I do this using the `filename` construction? Could this work? Are
there any security / performance issues?
--
martijn van exel -+- [EMAIL PROTECTED] -+- http://huizen.dds.nl/~mvexel/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]