At 00:28 -0600 02.02.2001, Andy Berkvam wrote:
>do { $name = tmpnam() }
> until $fh = IO::File->new($name, O_RDWR|O_CREAT|O_EXCL);
Weird. I have no idea why, but this is opening a file read-only (a -w flag
would have told you that :).
Here is a workaround:
use Symbol;
$fh = gensym;
do { $name = tmpnam }
until ! -e $name && open $fh, "+> $name";
Yes, not quite atomic. But sysopen() has the same problem IO::File->new
has. I don't know why this didn't come up before.
Also note this opens the file in the current working directory. I
sometimes prefer something like:
use File::Spec::Functions qw(:DEFAULT tmpdir);
use Symbol;
$fh = gensym;
do { $name = catdir(tmpdir, tmpnam) }
until ! -e $name && open $fh, "+> $name";
That should open it in the $ENV{TMPDIR} or whatever, which should be at
HD:Temporary Items: by default.
>$fh->autoflush(1);
$fh is no longer an object, so:
select((select($fh), $|++)[0]);
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/