in reply to temporary file

See Using Temporary Files in Perl for a discussion on secure and robust methods for creating and manipulating temporary files.

Based upon your described requirements, the following code using the new_tmpfile method of IO::File may suffice:

use IO::File; my $fh = IO::File->new_tmpfile; . . . $fh->seek(0, 0); print STDOUT $_ foreach <$fh>; $fh->close;

This code creates a temporary file using the new_tmpfile method of IO::File - This method creates a temporary file, based on the POSIX tmpfile() function or tmpfile() from glibc if using Perl I/O abstraction, and then, where possible, unlinks the file while still holding it open. The result is an anonymous file handle suitable for the temporary storage of data - The data is stored in a stdio stream. The only disadvantage with this method of file name generation is that the temporary file cannot be referenced other than through the returned file handle.

The perlfunc:seek function is then used to move the current read/write pointer within the file back to the start of the file, allowing the process output to be re-read in full for reporting to STDOUT.