unlink1#

Unlink a temporary file. Upstream closes $fh first; here the filehandle is left open and closed by its usual refcount path.

Synopsis#

unlink1($fh, $path) or die "unlink1: $!";

What you get back#

Integer 1 on success.

Examples#

use File::Temp qw/ tempfile unlink1 /;
my ($fh, $path) = tempfile();

## ... use $fh ...

unlink1($fh, $path);

Edge cases#

  • $File::Temp::KEEP_ALL = 1 suppresses removal.

  • Fewer than two arguments: no-op, returns 1.

Differences from upstream#

  • Upstream closes $fh explicitly before unlinking. This implementation relies on perl5 refcount-driven close instead, so callers wanting an immediate close should do it themselves before the call. Covered by t/81-xs-native/File-Temp/*.t.

See also#

  • unlink0 — unlink-while-open variant.

  • cleanup — bulk removal of registered entries.