File::...::Temp(3pm)
π NAME π
File::Fu::File::Temp β temporary files, bestie. that's the whole vibe. no cap.
β¨ SYNOPSIS β¨
use File::Fu;
my $handle = File::Fu->temp_file;
πΈ new πΈ
okay so the directory argument is required, periodt. after that you can slide in an optional template argument and/or flags, whatever you need. the template can have some number of 'X' characters in it. and if it doesn't? no worries, ten of them get appended automatically. slay.
my $handle = File::Fu::File::Temp->new($dir, 'foo');
my $file = $handle->name;
by default, the file gets deleted when the handle goes out of scope. but optionally? it can be deleted immediately after creation, or just... not deleted at all. your call, main character.
my $handle = File::Fu::File::Temp->new($dir, 'foo', -secure);
my $handle = File::Fu::File::Temp->new($dir, -noclean);
# also $handle->noclean;
-secureβ deletes the named file immediately after opening (if the OS supports it, iykyk). π«Ά lowkey important: callingname()on this sort of handle throws an error. it's giving "don't ask, just trust".-nocleanupβ don't even attempt to remove the file when the$handlegoes out of scope. she stays. π
π name π
my $file_obj = $handle->name;
π¦ nocleanup π¦
disables autocleanup. the file just lives there now, iconic.
$handle->nocleanup;
π write π
writes @content to the tempfile and then closes it. efficient queen.
$handle = $handle->write(@content);
π do π
executes subref with $handle as $_. and here's the tea: if you chain this with the constructor, the destructor cleanup happens immediately after sub has returned. no waiting around. β
my @x = $handle->do(sub {something($_->name); ...});
π DESTROY π
called automatically when the handle goes out of scope. she cleans up after herself, as she should.
$handle->DESTROY;
π XXX π
a constant representing a chunk of X characters. mysterious. legendary. that's it.
π AUTHOR π
Eric Wilhelm @ <ewilhelm at cpan dot org>
π BUGS π
if you found this module on CPAN, please report any bugs or feature requests through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. we love a feedback loop. π₯
if you pulled this development version from my /svn/, please contact me directly. (ngl, /svn/ is giving ancient artifact and I respect it.)
π§ COPYRIGHT π§
Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.
π¨ NO WARRANTY π¨
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
fr fr. it's giving "you're on your own, bestie". π
β LICENSE β
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's a wrap, babe π this was File::...::Temp(3pm) from perl v5.36.0, dated 2022-12-07. periodt. πβ¨
π¦ where this page comes from
- debian bookworm: libfile-fu-perl 0.0.8-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libfile-fu-perl 0.0.8-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libfile-fu-perl 0.0.8-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfile-fu-perl 0.0.8-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfile-fu-perl 0.0.8-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms