dagolden / Path-Tiny

File path utility
41 stars 59 forks source link

A File::Temp object is created as an opened file, but the cached_temp is not open #280

Closed robrwo closed 1 year ago

robrwo commented 1 year ago

When you create a File::Temp object, the object is actually an open file handle:

use feature 'say';

use File::Temp;
use Scalar::Util qw/ openhandle /;

my $tmp = File::Temp->new;
say openhandle($tmp); # returns a true value

but the file seems to be closed when creating one through Path::Tiny:

use feature 'say';

use Path::Tiny;
use Scalar::Util qw/ openhandle /;

my $path = Path::Tiny->tempfile; 
my $tmp  = $path->cached_temp;
say openhandle($tmp); # should be true, but returns undef
robrwo commented 1 year ago

Actually, I see in the tempfile method that you close the filehandle, and it is documented.