Hello everyone,

I am using the tmpdir function of File::Spec::VMS, which causes some
problems.
The current version of this function is:
  my $tmpdir;
  sub tmpdir {
    return $tmpdir if defined $tmpdir;
    foreach ('sys$scratch', $ENV{TMPDIR}) {
        next unless defined && -d && -w _;
        $tmpdir = $_;
        last;
    }
    $tmpdir = '' unless defined $tmpdir;
    return $tmpdir;
  }
This returns sys$scratch, which gives problems when used in catfile.
  print File::Spec->catfile(File::Spec->tmpdir, 'myfile.ext'), "\n";
gives [.sys$scratch]myfile.ext, which is not a good file specification.

It has been suggested in this group that catpath should be used instead of
catfile, but then the result of tmpdir is used as a volume specification,
which is strange because the function is called 'tmpdir', not 'tmpvol'. It
is better to look up the logical sys$scratch in %ENV.

I would like to suggest to change tmpdir as follows:
  my $tmpdir;
  sub tmpdir {
    return defined($tmpdir) ? $tmpdir :
           ($tmpdir = (grep {defined && -d && -w} map {$ENV{$_}}
qw{sys$scratch TMPDIR})[0] || '');  }
As you can probably tell from this, I like one-liners, but Outlook may have
spoilt it. :-)
This works well on my box (OpenVMS 7.2, Perl 5.005 or Perl 5.6.

Best regards.
--
Nico Verwer
[EMAIL PROTECTED]

Reply via email to