File::...::Temp(3pm)

πŸ“¦
version 0.0.8 Β· 2 versions
  • 0.0.8 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.0.8 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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: calling name() 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 $handle goes 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>

http://scratchcomputing.com/


πŸ™ˆ 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 (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