Home

Search this site:
 

Horshack’s
very
own site

 

This is Bavaria, Germany!
You will find links to Perl,
bootdisks for system administration,
a lot of Linux,
Windows administration
and some personal belongings.
Creating a temporary file

Creating a temporary file

You need a temporary file which you want to delete after this run of the programm.
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp;

# XXXX is getting replaced by something
# which does not exist yet. Directory is cwd
my($fh,$filename) = File::Temp::tempfile('myapplic_XXXX');
print "temporary \$filename is $filename\n";
print ${fh} "Something of temporary value\n";
close $fh;
# Do something with the file
system "some_converter_program --input=$filename --output=real.pdf";
# file exists after ending of this program
# -> I have to delete it on my own
unlink $filename;
Impressum