-
-
Save hongz1/35cd9014b3bdad5f235dbb3e1d0a6f2f to your computer and use it in GitHub Desktop.
An example Perl program that uses File::Temp to create a temporary directory for the time of program execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Cwd; | |
use File::Temp; | |
# Remember the current directory | |
my $oldcwd = getcwd; | |
# Create a temporary directory | |
my $dir = File::Temp->newdir; | |
# Go to the temporary directory | |
chdir $dir; | |
# ... do your stuff, create files in the temporary directory ... | |
# Go back to the previous directory | |
chdir $oldcwd; | |
# The temporary directory will be deleted when the program exits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment