Tuesday, March 3, 2009

Temp file in Perl

Use the following to generate a temporary file in Perl:


use File::Temp;
my $fh = tempfile;

print $fh "temp data";


Also, this finds the directory of the Perl script being executed:


use FindBin;
my $program_dir = $FindBin::Bin;



This, and some other useful Perl things, are found here:

http://www.perl.com/pub/a/2003/05/29/treasures.html

2 comments:

Demon said...

Perl is the best scripting language for Text processing and handle regex. I have posted few articles related to those at my blog

http://icfun.blogspot.com/search/label/perl

Also Perl's Cpan has lots of support that I don't even need to think extra while developing project. I didn't find such help on other programming language except Java and .NET

eric said...

Thanks for the link! I'll definitely be referring to your blog. I like to write as little new perl code as possible!