```{index} single: tempnam; File::Temp function ``` ```{index} single: File::Temp::tempnam; Perl function ``` # tempnam Return a candidate filename under `$dir` starting with `$prefix` — does not create the file. ## Synopsis ```perl my $name = tempnam('/var/tmp', 'cache_'); ``` ## What you get back A full path string `"$dir/${prefix}XXXXXXXX"` with the `X`s replaced by random characters. The caller is responsible for opening the file, and there is a race between name selection and open. ## Examples ```perl use File::Temp qw/ tempnam /; my $name = tempnam('/tmp', 'sess-'); open my $fh, '>', $name or die; ``` ## Edge cases - Wrong arg count: croaks with a usage message. - Like `mktemp`, unsafe against attackers — prefer `tempfile`. ## Differences from upstream Fully compatible with upstream `File::Temp` 0.2312. ## See also - `tempfile` — race-safe replacement returning both filehandle and name. - `mktemp` — similar idea with a caller-supplied template.