in reply to TIMTOWTDI Challenge: Create a filename
Assuming a quick-and-dirty temporary filename is desired:
my $filename = int rand 2**31;
Or pick a large random number of your choice. Plus if you need to generate the *same* temporary filenames on successive runs, you can set the seed for rand() ahead of time.
Similar in nature, but random alphanumerics, not unlike what File::Temp does internally:
my @chars = ('a' .. 'z', 'A' .. 'Z'); my $filename = join("", map { $chars[int rand(0+@chars)] } 0 .. 7);
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: TIMTOWTDI Challenge: Create a filename
by pobocks (Chaplain) on Jan 11, 2009 at 07:18 UTC |
In Section
Meditations