cleaner way to unlink a File::Temp file?
I'm currently doing this
my $tmpf = File::Temp->new开发者_C百科;
$tmpf->unlink_on_destroy(1);
but it seems like this could be cleaner.. something like
my $tmpf = File::Temp->new({unlink => 1});
is something like the latter possible?
You can also set this flag in the constructor:
my $tmp = File::Temp->new( UNLINK => 1, SUFFIX => '.dat' );
But it is unnecessary. From the perldoc File::Temp:
by default the object is constructed as if tempfile was called without options, but with the additional behaviour that the temporary file is removed by the object destructor if UNLINK is set to true (the default).
精彩评论