[Bioperl-l] tempfiles/tempdirs

Jason Stajich jason@cgt.mc.duke.edu
Thu, 17 Jan 2002 13:25:56 -0500 (EST)


I've been looking through the code to see where we use the Root::IO
methods, tempfile and tempdir - not a whole lot.  I am concerned because
we seem to be leaving some clutter after running tests and File::Temp
files are not necessarily removed when the filehandle closes.  This can be
a problem for people running CGI's or many many analyses within a single
perl session.

It seems to me that the IO::File way of doing tempfiles

my $fh = IO::File->new_tempfile

might be more sane.  This is r/w capable handle so after writing to it -
we can rewind th fh and access what has been written.  This is essentially
the behavior needed by some of the parsers.

We do need unique tempfile names to be output for executing programs and
IO::File provides the methods tmpnam() to achieve this.  I would like to
be able to rely on IO::File being installed (which it appears to be even
on perl 5.004_04).  you do have to test that tmpnam returns something
valid by doing
do { $name = tmpnam() } until sysopen(TMP, $name, .... );
while File::Temp assures that your temporary name is valid.

Does anyone have opinions here?  I like the filehandle method better. And
I think we can be creative in our tempname generation in the modules that
need it.

-jason

-- 
Jason Stajich
Duke University
jason@cgt.mc.duke.edu