- SEE ALSO
- COPYRIGHT AND LICENSE
File::Slurper::Temp - File::Slurper + File::Temp
This document describes version 0.006 of File::Slurper::Temp (from Perl distribution File-Slurper-Temp), released on 2019-07-21.
Use like you would use File::Slurper's
use File::Slurper::Temp qw(write_text write_binary); write_text("/tmp/foo.txt", "some text"); write_binary("/tmp/bar", $somedata);
use File::Slurper::Temp qw(write_text_to_tempfile write_binary_to_tempfile); my $filename1 = write_text_to_tempfile("some text"); my $filename2 = write_binary_to_tempfile($somedata);
This module's version of
write_binary write to temporary file first using File::Temp's tempfile() before renaming to the final destination path using Perl's rename(). If the destination path is originally a symlink, it will be replaced with a regular file by
rename(). This can avoid symlink attack.
In addition the above two functions, this module also provides "write_text_to_tempfile" and "write_binary_to_tempfile". You don't have to specify destination path but just content to write, and the functions will return the temporary filename created.
write_text($filename, $content [ , $encoding, $crlf ])
Just like the original File::Slurper's version, except will write to temporary file created by File::Temp's
tempfile first, then rename the temporary file using Perl's
rename(). The function will croak if
By default, the temporary file is created in the same directory as
DIR => dirname($filename). If you want to set a specific temporary directory, set
$FILE_TEMP_DIR (see source code). But keep in mind that
rename() doesn't work cross-device.
$tempname = write_text_to_tempfile($content [ , $encoding, $crlf ])
Temporary file is created with default option (
$tempname = write_binary_to_tempfile($content)
Please visit the project's homepage at https://metacpan.org/release/File-Slurper-Temp.
Source repository is at https://github.com/perlancar/perl-File-Slurper-Temp.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=File-Slurper-Temp
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
This software is copyright (c) 2019, 2017 by firstname.lastname@example.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.