Perl script code example to create temporary file-tempfile()

Here is a perl script example how to create temporary file on the file system:
TEMPLATE DIR AND SUFIX are option !


#!/usr/bin/perl
my $tempfile = new File::Temp ( TEMPLATE => 'tempfile_XXX', DIR => '/tmp/', SUFIX => '' );

this will create a temporary file in /tmp/ directory with name tempfile_XXX where X is random generated character.

Leave a Reply

You must be logged in to post a comment.