Hello- >From time to time I need a subroutine to generate a temporary file name so I created an imperfect routine (shown below) to generate a file name based on the current time. The problem with this is that it will create only 1 'unique' name every second, and when the day rolls over, it will start duplicating those supposedly unique file names.
None of this has been an issue in the past, but now it is, so I'm asking if any of you have a better, more unique, algorithm equal to the task. If it is not guaranteed to be unique, it is OK if I have to call it 4 or 5 times until I get a unique file name. ======================================= use warnings; use strict; . . . sub tempname { my $junk; my ($sec, $min, $hrs, $day, $mon) = (localtime)[0..4]; $mon += 1; $sec += 100; $min += 100; $hrs += 100; $day += 100; $mon += 100; ($junk,$sec) = unpack("A1 A2",$sec); ($junk,$min) = unpack("A1 A2",$min); ($junk,$hrs) = unpack("A1 A2",$hrs); ($junk,$day) = unpack("A1 A2",$day); ($junk,$mon) = unpack("A1 A2",$mon); return "$mon$day$hrs$min$sec"; } _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs