```{index} single: unlink_on_destroy; File::Temp function ``` ```{index} single: File::Temp::unlink_on_destroy; Perl function ``` # unlink_on_destroy Toggle or query whether a `File::Temp` object unlinks its file when destroyed. ## Synopsis ```perl my $flag = $tmp->unlink_on_destroy; # getter $tmp->unlink_on_destroy(0); # keep the file $tmp->unlink_on_destroy(1); # remove on destruction ``` ## What you get back The new (or current) flag value as an integer: `1` if the file will be removed when the object is destroyed, `0` otherwise. ## Examples ```perl my $tmp = File::Temp->new; $tmp->unlink_on_destroy(0); ## $tmp->filename survives after $tmp goes out of scope ``` ## Edge cases - Called on something that is not a `File::Temp` object: returns `1` without touching state. - Setting to a true value on an object whose file is no longer tracked does not re-register it. ## Differences from 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 by `t/81-xs-native/File-Temp/*.t`. ## See also - `File::Temp->new` — constructor whose default is `UNLINK => 1`. - `cleanup` — force-drain all registered cleanups now. - `unlink0` — verified unlink used internally by scalar-context tempfile.