unlink_on_destroy#
Toggle or query whether a File::Temp object unlinks its file when destroyed.
Σύνοψη#
my $flag = $tmp->unlink_on_destroy; # getter
$tmp->unlink_on_destroy(0); # keep the file
$tmp->unlink_on_destroy(1); # remove on destruction
Τι επιστρέφεται#
The new (or current) flag value as an integer: 1 if the file will be removed when the object is destroyed, 0 otherwise.
Παραδείγματα#
my $tmp = File::Temp->new;
$tmp->unlink_on_destroy(0);
## $tmp->filename survives after $tmp goes out of scope
Οριακές περιπτώσεις#
Called on something that is not a
File::Tempobject: returns1without touching state.Setting to a true value on an object whose file is no longer tracked does not re-register it.
Διαφορές από το upstream#
The flag is stored in an internal map rather than the blessed glob’s hash slot. Code that pokes at
%{*$fh}directly will not observe the flag; use the method. Covered byt/81-xs-native/File-Temp/*.t.
Δείτε επίσης#
File::Temp->new- constructor whose default isUNLINK => 1.cleanup- force-drain all registered cleanups now.unlink0- verified unlink used internally by scalar-context tempfile.